diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b363461bc099f664f047abc68b57c7e2c1a05ebc..d414d9a652c61cc3231668364469cfcd363c4581 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 0a2c733dcf3618d098ada07b8cc5155eab36be18..334f978bf48e819f43a91ba915d94136a3b40a9e 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 8217cd1005fffb2601e4da4657590badaa688d65..9b2e1cd4a8cf34ddac7043e42fb4c9d0524e8741 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 61c92b5dc48049e6dd7f51ffc130111b0d200495..7f946d0b3a590e578d796146c203250a1ccdf64d 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 30d8c35d65ee2b3713420c7389a6c1bba5344730..e671330c11603bb2ba5f073d6a7072f68b5f4db9 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 e5ecc25fae946b522ca7553ee934d8e4c628512c..f722c20ffece4f2672dabc1ddaa5b119957ca1c9 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 983fa24c5601b9b21bf884707085b856673f2a4f..662606de9653f0694c94c66a4bdd31a8e6b5d88f 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 a2810b2b8fdee68a75c66c7ee48eac5efc22d37b..fdc5ac73732255dae165543b60f6849bf00784f4 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 961a43d72e1198c05be5f5666b3825b8023bb308..8cb215c0c06b9b59d02a243e86de958fb2c5673f 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 c925fcbae643d0cf2151c604b8f803956ae7bdd9..ba59881dd453396388c6dbbcba514824ee97b8cc 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