From 3b7b2ed5934bab38de7044d60d12284ad4ed080a Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Mon, 27 Jan 2025 21:26:16 +0000 Subject: [PATCH] Setting ansible lint 03 --- .gitlab-ci.yml | 22 +++++++++++++++++++ playbook_example_04_docker_images.yml | 5 +++-- roles/docker_containers/meta/main.yml | 2 +- .../tasks/printer_compose_down.yml | 1 - .../tasks/printer_compose_stop.yml | 1 - .../tasks/printer_host_cups_disable.yml | 8 ++++++- .../docker_images/tasks/docker_image_app.yml | 3 ++- .../docker_images/tasks/docker_image_cups.yml | 3 ++- .../tasks/docker_image_proxy.yml | 3 ++- roles/docker_images/tasks/main.yml | 11 +++++++--- 10 files changed, 47 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b363461..d414d9a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,6 +15,8 @@ variables: PLAYBOOK_NAME_FOR_ROLE_TEST: "playbook_example_01_test.yml" PLAYBOOK_NAME_FOR_ROLE_DEPENDENCIES: "playbook_example_02_dependencies.yml" PLAYBOOK_NAME_FOR_ROLE_CLONE_REPOSITORIES: "playbook_example_03_clone_repositories.yml" + PLAYBOOK_NAME_FOR_ROLE_DOCKER_IMAGES: "playbook_example_04_docker_images.yml" + PLAYBOOK_NAME_FOR_ROLE_DOCKER_CONTAINERS: "playbook_example_05_docker_containers.yml" stages: - debug @@ -75,3 +77,23 @@ role-clone-repositories: - echo "Running ansible-lint tests at the role-> 'clone_repositories'" - ansible-lint $PLAYBOOK_NAME_FOR_ROLE_CLONE_REPOSITORIES allow_failure: false + +role-docker-images: + stage: lint-tests + before_script: + - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* + - pip3 install -r requirements.txt + script: + - echo "Running ansible-lint tests at the role-> 'docker_images'" + - ansible-lint $PLAYBOOK_NAME_FOR_ROLE_DOCKER_IMAGES + allow_failure: false + +role-docker-containers: + stage: lint-tests + before_script: + - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* + - pip3 install -r requirements.txt + script: + - echo "Running ansible-lint tests at the role-> 'docker_containers'" + - ansible-lint $PLAYBOOK_NAME_FOR_ROLE_DOCKER_CONTAINERS + allow_failure: false diff --git a/playbook_example_04_docker_images.yml b/playbook_example_04_docker_images.yml index 0a2c733..334f978 100644 --- a/playbook_example_04_docker_images.yml +++ b/playbook_example_04_docker_images.yml @@ -1,7 +1,8 @@ --- # Runs example for -- hosts: - - example_servers_group +- name: Playbook for running the role 'docker_images' + hosts: + - example_servers_group roles: - docker_images diff --git a/roles/docker_containers/meta/main.yml b/roles/docker_containers/meta/main.yml index 8217cd1..9b2e1cd 100644 --- a/roles/docker_containers/meta/main.yml +++ b/roles/docker_containers/meta/main.yml @@ -1,7 +1,7 @@ --- galaxy_info: - role_name: docker-containers + role_name: docker_containers description: Role to work with the containers for the c3InfoDesk sytems author: fejao company: cccv.de diff --git a/roles/docker_containers/tasks/printer_compose_down.yml b/roles/docker_containers/tasks/printer_compose_down.yml index 61c92b5..7f946d0 100644 --- a/roles/docker_containers/tasks/printer_compose_down.yml +++ b/roles/docker_containers/tasks/printer_compose_down.yml @@ -11,4 +11,3 @@ ansible.builtin.debug: var: ret_docker_compose_down when: c3infodesk_printer_docker_compose_down_debug | bool - diff --git a/roles/docker_containers/tasks/printer_compose_stop.yml b/roles/docker_containers/tasks/printer_compose_stop.yml index 30d8c35..e671330 100644 --- a/roles/docker_containers/tasks/printer_compose_stop.yml +++ b/roles/docker_containers/tasks/printer_compose_stop.yml @@ -11,4 +11,3 @@ ansible.builtin.debug: var: ret_docker_compose_stop when: c3infodesk_printer_docker_compose_stop_debug | bool - diff --git a/roles/docker_containers/tasks/printer_host_cups_disable.yml b/roles/docker_containers/tasks/printer_host_cups_disable.yml index e5ecc25..f722c20 100644 --- a/roles/docker_containers/tasks/printer_host_cups_disable.yml +++ b/roles/docker_containers/tasks/printer_host_cups_disable.yml @@ -21,6 +21,8 @@ when: - cups_status is defined - cups_status != 'masked' + register: ret_stop_cups + changed_when: ret_stop_cups.rc != 0 - name: DISABLE CUPS | Disable the running CUPS on target ansible.builtin.command: @@ -30,6 +32,8 @@ when: - cups_status is defined - cups_status != 'masked' + register: ret_disable_cups + changed_when: ret_disable_cups.rc != 0 - name: DISABLE CUPS | Mask the running CUPS on target ansible.builtin.command: @@ -38,4 +42,6 @@ # when: cups_status != 'masked' when: - cups_status is defined - - cups_status != 'masked' \ No newline at end of file + - cups_status != 'masked' + register: ret_mask_cups + changed_when: ret_mask_cups.rc != 0 diff --git a/roles/docker_images/tasks/docker_image_app.yml b/roles/docker_images/tasks/docker_image_app.yml index 983fa24..662606d 100644 --- a/roles/docker_images/tasks/docker_image_app.yml +++ b/roles/docker_images/tasks/docker_image_app.yml @@ -18,10 +18,11 @@ chdir: "{{ c3infodesk_printer_folder }}" register: build_img_result when: result_check_image.images | length <= 0 + changed_when: build_img_result.rc != 0 - name: APP | DEBUG -> Output from creating the docker image ansible.builtin.debug: msg: "{{ build_img_result }}" when: - c3infodesk_printer_debug_create_image_app | bool - - build_img_result is defined \ No newline at end of file + - build_img_result is defined diff --git a/roles/docker_images/tasks/docker_image_cups.yml b/roles/docker_images/tasks/docker_image_cups.yml index a2810b2..fdc5ac7 100644 --- a/roles/docker_images/tasks/docker_image_cups.yml +++ b/roles/docker_images/tasks/docker_image_cups.yml @@ -23,10 +23,11 @@ chdir: "{{ c3infodesk_printer_folder }}" register: build_img_result when: result_check_image.images | length <= 0 + changed_when: build_img_result.rc != 0 - name: CUPS | DEBUG -> Output from creating the docker image ansible.builtin.debug: msg: "{{ build_img_result }}" when: - c3infodesk_printer_debug_create_image_cups | bool - - build_img_result is defined \ No newline at end of file + - build_img_result is defined diff --git a/roles/docker_images/tasks/docker_image_proxy.yml b/roles/docker_images/tasks/docker_image_proxy.yml index 961a43d..8cb215c 100644 --- a/roles/docker_images/tasks/docker_image_proxy.yml +++ b/roles/docker_images/tasks/docker_image_proxy.yml @@ -18,10 +18,11 @@ chdir: "{{ c3infodesk_printer_folder }}" register: build_img_result when: result_check_image.images | length <= 0 + changed_when: build_img_result.rc != 0 - name: PROXY | DEBUG -> Output from creating the docker image ansible.builtin.debug: msg: "{{ build_img_result }}" when: - c3infodesk_printer_debug_create_image_cups | bool - - build_img_result is defined \ No newline at end of file + - build_img_result is defined diff --git a/roles/docker_images/tasks/main.yml b/roles/docker_images/tasks/main.yml index c925fcb..ba59881 100644 --- a/roles/docker_images/tasks/main.yml +++ b/roles/docker_images/tasks/main.yml @@ -1,6 +1,11 @@ --- # tasks file for docker-images -- import_tasks: docker_image_cups.yml -- import_tasks: docker_image_app.yml -- import_tasks: docker_image_proxy.yml +- name: Create the docker image for cups + ansible.builtin.import_tasks: docker_image_cups.yml + +- name: Create the docker image for app + ansible.builtin.import_tasks: docker_image_app.yml + +- name: Create the docker image for proxy + ansible.builtin.import_tasks: docker_image_proxy.yml -- GitLab