From b62bdefa85c892a4f58f9c6ad75e9cd2465b9d34 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 11:27:06 +0100 Subject: [PATCH 01/18] Updated the README.md file --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ac1cdf8..c196eba 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,19 @@ ## WIP - [x] Finish the roles for deploying the **c3InfoDesk Printer**. - - [x] dependencies - - [x] clone_repositories - - [x] docker_images - - [x] docker_containers -- [x] Set ansible-lint for the roles. -- [ ] Add molecule tests. + - [x] [dependencies](https://git.cccv.de/fejao/c3infodesk-deployment/-/tree/main/roles/dependencies) + - [x] [clone_repositories](https://git.cccv.de/fejao/c3infodesk-deployment/-/tree/main/roles/clone_repositories) + - [x] [docker_images](https://git.cccv.de/fejao/c3infodesk-deployment/-/tree/main/roles/docker_images) + - [x] [docker_containers](https://git.cccv.de/fejao/c3infodesk-deployment/-/tree/main/roles/docker_containers) + - [x] [oh_my_bash](https://git.cccv.de/fejao/c3infodesk-deployment/-/tree/main/roles/oh_my_bash) +- [x] Create molecule tests for the roles. - [x] [dependencies](https://git.cccv.de/fejao/c3infodesk-deployment/-/commit/c04809f7f0644f2cdb1e8affb02ed6c4b623252a) - [x] [clone_repositories](https://git.cccv.de/fejao/c3infodesk-deployment/-/commit/0b9aee5d2d9768b5f77494300e88857b9a3aceee) - [x] [docker_images](https://git.cccv.de/fejao/c3infodesk-deployment/-/commit/a4d532169beed8a18bed536bb1e9a346b6a7b5c0) - [x] [docker_containers](https://git.cccv.de/fejao/c3infodesk-deployment/-/commit/a4d532169beed8a18bed536bb1e9a346b6a7b5c0) - - [x] oh_my_bash + - [x] [oh_my_bash](https://git.cccv.de/fejao/c3infodesk-deployment/-/commit/6bf23eb4335ad92ba42b9d1872abf497aed735cc) +- [x] Set ansible-lint for the roles. +- [ ] Add molecule tests to CI-CD ## What is this? -- GitLab From dfe00d4de5b759c61fe7cc3c7d32031ddebd48ec Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 11:32:13 +0100 Subject: [PATCH 02/18] Minor fixes --- roles/clone_repositories/README.md | 2 +- roles/oh_my_bash/molecule/default/converge.yml | 7 ------- roles/oh_my_bash/molecule/default/verify.yml | 8 -------- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/roles/clone_repositories/README.md b/roles/clone_repositories/README.md index f795998..358087b 100644 --- a/roles/clone_repositories/README.md +++ b/roles/clone_repositories/README.md @@ -1,4 +1,4 @@ -# clone-repositories role +# clone_repositories role This ansible-role for dealing with cloning the repositories necessary for deploying the system used from **c3infodesk**. diff --git a/roles/oh_my_bash/molecule/default/converge.yml b/roles/oh_my_bash/molecule/default/converge.yml index ccd0d7e..cf5b357 100644 --- a/roles/oh_my_bash/molecule/default/converge.yml +++ b/roles/oh_my_bash/molecule/default/converge.yml @@ -10,13 +10,6 @@ extensions: - 'yml' - # - name: MOLECULE | COVERGE | PRE-TASKS | VARIABLES | From -> ../../vars - # ansible.builtin.include_vars: - # dir: ../../vars - # depth: 1 - # extensions: - # - 'yml' - - name: MOLECULE | COVERGE | PRE-TASKS | VARIABLES | From -> ../../../../inventories/group_vars ansible.builtin.include_vars: dir: ../../../../inventories/group_vars diff --git a/roles/oh_my_bash/molecule/default/verify.yml b/roles/oh_my_bash/molecule/default/verify.yml index 5442dee..dfef6dc 100644 --- a/roles/oh_my_bash/molecule/default/verify.yml +++ b/roles/oh_my_bash/molecule/default/verify.yml @@ -51,10 +51,6 @@ failed_when: - not check_installed.stat.exists - # - name: MOLECULE | VERIFY | TEST | DEBUG | Oh-My-Bash installed. - # ansible.builtin.debug: - # msg: "{{ check_installed }}" - - name: MOLECULE | VERIFY | TEST | Oh-My-Bash is enabled. ansible.builtin.lineinfile: path: "{{ ansible_env.HOME }}/.bashrc" @@ -64,10 +60,6 @@ register: check_enabled failed_when: check_enabled.changed | bool - # - name: MOLECULE | VERIFY | TEST | DEBUG | Oh-My-Bash is enabled. - # ansible.builtin.debug: - # msg: "{{ check_enabled }}" - - name: MOLECULE | VERIFY | TEST | Theme is setted. ansible.builtin.lineinfile: path: "{{ ansible_env.HOME }}/.bashrc" -- GitLab From b10c48973c8615d5d5d57b1e30aaa019dd96cc83 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 11:33:14 +0100 Subject: [PATCH 03/18] Updating the .gitlab-ci.yml file --- .gitlab-ci.yml | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 850aaaf..75fb674 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,9 @@ variables: ##### ##### ##### + IMAGE_NAME_SYNTAX: python:3.10.15-bullseye + IMAGE_NAME_LINT: python:3.10.15-bullseye + IMAGE_NAME_MOLECULE: geerlingguy/docker-ubuntu2204-ansible:latest INVENTORIES_PATH: "inventories/hosts" PLAYBOOK_PATH_FOR_ROLE_TEST: "ci-cd/01_test.yml" PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES: "ci-cd/02_dependencies.yml" @@ -23,7 +26,8 @@ stages: ### syntax-test: stage: syntax-check - image: python:3.10.15-bullseye + # image: python:3.10.15-bullseye + image: $IMAGE_NAME_SYNTAX before_script: - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - pip3 install -r ci-cd/requirements.txt @@ -160,23 +164,24 @@ lint-oh-my-bash: ### ### molecule ### -# molecule-test: -# stage: molecule -# # image: docker:latest -# # image: docker:27.5.1-alpine3.21 -# image: docker:27.5.1-dind -# before_script: -# - apk add --no-cache python3 py3-pip -# - rm /usr/lib/python*/EXTERNALLY-MANAGED -# - python3 -m ensurepip -# - pip3 install ansible ansible-lint molecule molecule-docker -# - pip3 install --user "molecule-plugins[docker]" -# script: -# - echo "Running ansible-lint tests at the role-> 'test'" -# - docker ps -a -# - cd roles/test -# - molecule test -# allow_failure: false +molecule-test: + stage: molecule + # image: docker:latest + # image: docker:27.5.1-alpine3.21 + # image: docker:27.5.1-dind + image: geerlingguy/docker-ubuntu2204-ansible:latest + before_script: + # - apk add --no-cache python3 py3-pip + # - rm /usr/lib/python*/EXTERNALLY-MANAGED + # - python3 -m ensurepip + - pip3 install ansible ansible-lint molecule molecule-docker + - pip3 install --user "molecule-plugins[docker]" + script: + - echo "Running ansible-lint tests at the role-> 'test'" + - docker ps -a + # - cd roles/test + # - molecule test + allow_failure: false # molecule-test: # stage: molecule -- GitLab From 15f4226f2e4e0b4d92bc3edcc35d7765c39b25ea Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 12:26:10 +0100 Subject: [PATCH 04/18] Refactoring CI-CD --- .gitlab-ci.yml | 192 +++++++++++++++++++++++++------------------------ 1 file changed, 100 insertions(+), 92 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 75fb674..d27bee8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,16 +21,23 @@ stages: - lint-tests - molecule +### +### SCRIPTS +### +.before_syntax_n_lint: &before_syntax_n_lint + - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* + - pip3 install -r ci-cd/requirements.txt + ### ### SYNTAX-CHECK ### syntax-test: stage: syntax-check - # image: python:3.10.15-bullseye image: $IMAGE_NAME_SYNTAX before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt + # - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* + # - pip3 install -r ci-cd/requirements.txt + - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_TEST @@ -38,7 +45,7 @@ syntax-test: syntax-dependencies: stage: syntax-check - image: python:3.10.15-bullseye + image: $IMAGE_NAME_SYNTAX before_script: - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - pip3 install -r ci-cd/requirements.txt @@ -49,7 +56,7 @@ syntax-dependencies: syntax-clone-repositories: stage: syntax-check - image: python:3.10.15-bullseye + image: $IMAGE_NAME_SYNTAX before_script: - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - pip3 install -r ci-cd/requirements.txt @@ -60,7 +67,7 @@ syntax-clone-repositories: syntax-docker-images: stage: syntax-check - image: python:3.10.15-bullseye + image: $IMAGE_NAME_SYNTAX before_script: - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - pip3 install -r ci-cd/requirements.txt @@ -71,7 +78,7 @@ syntax-docker-images: syntax-docker-containers: stage: syntax-check - image: python:3.10.15-bullseye + image: $IMAGE_NAME_SYNTAX before_script: - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - pip3 install -r ci-cd/requirements.txt @@ -82,7 +89,7 @@ syntax-docker-containers: syntax-oh-my-bash: stage: syntax-check - image: python:3.10.15-bullseye + image: $IMAGE_NAME_SYNTAX before_script: - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - pip3 install -r ci-cd/requirements.txt @@ -91,97 +98,98 @@ syntax-oh-my-bash: - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH allow_failure: false -### -### LINT-TESTS -### -lint-test: - stage: lint-tests - image: python:3.10.15-bullseye - before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt - script: - - echo "Running ansible-lint tests at the role-> 'test'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST - allow_failure: false +# ### +# ### LINT-TESTS +# ### +# lint-test: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* +# - pip3 install -r ci-cd/requirements.txt +# script: +# - echo "Running ansible-lint tests at the role-> 'test'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST +# allow_failure: false -lint-dependencies: - stage: lint-tests - image: python:3.10.15-bullseye - before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt - script: - - echo "Running ansible-lint tests at the role-> 'dependencies'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES - allow_failure: false +# lint-dependencies: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* +# - pip3 install -r ci-cd/requirements.txt +# script: +# - echo "Running ansible-lint tests at the role-> 'dependencies'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES +# allow_failure: false -lint-clone-repositories: - stage: lint-tests - image: python:3.10.15-bullseye - before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt - script: - - echo "Running ansible-lint tests at the role-> 'clone_repositories'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES - allow_failure: false +# lint-clone-repositories: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* +# - pip3 install -r ci-cd/requirements.txt +# script: +# - echo "Running ansible-lint tests at the role-> 'clone_repositories'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES +# allow_failure: false -lint-docker-images: - stage: lint-tests - image: python:3.10.15-bullseye - before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt - script: - - echo "Running ansible-lint tests at the role-> 'docker_images'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES - allow_failure: false +# lint-docker-images: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* +# - pip3 install -r ci-cd/requirements.txt +# script: +# - echo "Running ansible-lint tests at the role-> 'docker_images'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES +# allow_failure: false -lint-docker-containers: - stage: lint-tests - image: python:3.10.15-bullseye - before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt - script: - - echo "Running ansible-lint tests at the role-> 'docker_containers'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS - allow_failure: false +# lint-docker-containers: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* +# - pip3 install -r ci-cd/requirements.txt +# script: +# - echo "Running ansible-lint tests at the role-> 'docker_containers'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS +# allow_failure: false -lint-oh-my-bash: - stage: lint-tests - image: python:3.10.15-bullseye - before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt - script: - - echo "Running ansible-lint tests at the role-> 'docker_containers'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH - allow_failure: false +# lint-oh-my-bash: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* +# - pip3 install -r ci-cd/requirements.txt +# script: +# - echo "Running ansible-lint tests at the role-> 'docker_containers'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH +# allow_failure: false -### -### molecule -### -molecule-test: - stage: molecule - # image: docker:latest - # image: docker:27.5.1-alpine3.21 - # image: docker:27.5.1-dind - image: geerlingguy/docker-ubuntu2204-ansible:latest - before_script: - # - apk add --no-cache python3 py3-pip - # - rm /usr/lib/python*/EXTERNALLY-MANAGED - # - python3 -m ensurepip - - pip3 install ansible ansible-lint molecule molecule-docker - - pip3 install --user "molecule-plugins[docker]" - script: - - echo "Running ansible-lint tests at the role-> 'test'" - - docker ps -a - # - cd roles/test - # - molecule test - allow_failure: false +# ### +# ### molecule +# ### +# molecule-test: +# stage: molecule +# # image: docker:latest +# # image: docker:27.5.1-alpine3.21 +# # image: docker:27.5.1-dind +# # image: geerlingguy/docker-ubuntu2204-ansible:latest +# image: $IMAGE_NAME_MOLECULE +# before_script: +# # - apk add --no-cache python3 py3-pip +# # - rm /usr/lib/python*/EXTERNALLY-MANAGED +# # - python3 -m ensurepip +# - pip3 install ansible ansible-lint molecule molecule-docker +# - pip3 install --user "molecule-plugins[docker]" +# script: +# - echo "Running ansible-lint tests at the role-> 'test'" +# - docker ps -a +# # - cd roles/test +# # - molecule test +# allow_failure: false # molecule-test: # stage: molecule -- GitLab From 7b7f71ef5e837ab2f677e2e43ec1ecfb03db6a92 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 12:29:33 +0100 Subject: [PATCH 05/18] Refactoring CI-CD --- .gitlab-ci.yml | 137 ++++++++++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 75 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d27bee8..46f588d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,8 +35,6 @@ syntax-test: stage: syntax-check image: $IMAGE_NAME_SYNTAX before_script: - # - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - # - pip3 install -r ci-cd/requirements.txt - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" @@ -47,8 +45,7 @@ syntax-dependencies: stage: syntax-check image: $IMAGE_NAME_SYNTAX before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt + - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'dependencies'" - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES @@ -58,8 +55,7 @@ syntax-clone-repositories: stage: syntax-check image: $IMAGE_NAME_SYNTAX before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt + - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'clone_repositories'" - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES @@ -69,8 +65,7 @@ syntax-docker-images: stage: syntax-check image: $IMAGE_NAME_SYNTAX before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt + - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_images'" - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES @@ -80,8 +75,7 @@ syntax-docker-containers: stage: syntax-check image: $IMAGE_NAME_SYNTAX before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt + - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS @@ -91,81 +85,74 @@ syntax-oh-my-bash: stage: syntax-check image: $IMAGE_NAME_SYNTAX before_script: - - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - - pip3 install -r ci-cd/requirements.txt + - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH allow_failure: false -# ### -# ### LINT-TESTS -# ### -# lint-test: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* -# - pip3 install -r ci-cd/requirements.txt -# script: -# - echo "Running ansible-lint tests at the role-> 'test'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST -# allow_failure: false +### +### LINT-TESTS +### +lint-test: + stage: lint-tests + image: $IMAGE_NAME_LINT + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'test'" + - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST + allow_failure: false -# lint-dependencies: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* -# - pip3 install -r ci-cd/requirements.txt -# script: -# - echo "Running ansible-lint tests at the role-> 'dependencies'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES -# allow_failure: false +lint-dependencies: + stage: lint-tests + image: $IMAGE_NAME_LINT + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'dependencies'" + - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES + allow_failure: false -# lint-clone-repositories: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* -# - pip3 install -r ci-cd/requirements.txt -# script: -# - echo "Running ansible-lint tests at the role-> 'clone_repositories'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES -# allow_failure: false +lint-clone-repositories: + stage: lint-tests + image: $IMAGE_NAME_LINT + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'clone_repositories'" + - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES + allow_failure: false -# lint-docker-images: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* -# - pip3 install -r ci-cd/requirements.txt -# script: -# - echo "Running ansible-lint tests at the role-> 'docker_images'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES -# allow_failure: false +lint-docker-images: + stage: lint-tests + image: $IMAGE_NAME_LINT + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'docker_images'" + - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES + allow_failure: false -# lint-docker-containers: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* -# - pip3 install -r ci-cd/requirements.txt -# script: -# - echo "Running ansible-lint tests at the role-> 'docker_containers'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS -# allow_failure: false +lint-docker-containers: + stage: lint-tests + image: $IMAGE_NAME_LINT + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'docker_containers'" + - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS + allow_failure: false -# lint-oh-my-bash: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* -# - pip3 install -r ci-cd/requirements.txt -# script: -# - echo "Running ansible-lint tests at the role-> 'docker_containers'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH -# allow_failure: false +lint-oh-my-bash: + stage: lint-tests + image: $IMAGE_NAME_LINT + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'docker_containers'" + - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH + allow_failure: false # ### -- GitLab From 7e8738b5fdbc604ec1f9e1a8441d3ac2ef0a0766 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 12:31:29 +0100 Subject: [PATCH 06/18] Refactring CI-CD --- .gitlab-ci.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 46f588d..2519289 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,10 @@ # image: python:3.10.15-bullseye +### +### VARIABLES +### variables: AUTHOR: fejao - ##### - ##### - ##### IMAGE_NAME_SYNTAX: python:3.10.15-bullseye IMAGE_NAME_LINT: python:3.10.15-bullseye IMAGE_NAME_MOLECULE: geerlingguy/docker-ubuntu2204-ansible:latest @@ -16,6 +16,9 @@ variables: PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS: "ci-cd/05_docker_containers.yml" PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH: "ci-cd/06_oh_my_bash.yml" +### +### STAGES +### stages: - syntax-check - lint-tests @@ -29,7 +32,7 @@ stages: - pip3 install -r ci-cd/requirements.txt ### -### SYNTAX-CHECK +### STAGE-SYNTAX-CHECK ### syntax-test: stage: syntax-check @@ -92,7 +95,7 @@ syntax-oh-my-bash: allow_failure: false ### -### LINT-TESTS +### STAGE-LINT-TESTS ### lint-test: stage: lint-tests @@ -156,7 +159,7 @@ lint-oh-my-bash: # ### -# ### molecule +# ### STAGE-MOLECULE # ### # molecule-test: # stage: molecule -- GitLab From 1f8129b48b79fa79001d10f7dfb58c713ff31cd1 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 13:02:28 +0100 Subject: [PATCH 07/18] Refactoring ci-cd --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2519289..ae9516b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,17 +31,24 @@ stages: - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - pip3 install -r ci-cd/requirements.txt + +.run_syntax_check: &run_syntax_check + - echo 'ROLE_PATH --> $ROLE_PATH' + ### ### STAGE-SYNTAX-CHECK ### syntax-test: stage: syntax-check image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST before_script: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_TEST + - *run_syntax_check allow_failure: false syntax-dependencies: -- GitLab From 0f2d612b2125a651a7530314f58d4bbd436f6d1e Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 13:05:32 +0100 Subject: [PATCH 08/18] REfactoring CI-CD --- .gitlab-ci.yml | 116 ++++++++++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae9516b..308f29c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,7 +33,7 @@ stages: .run_syntax_check: &run_syntax_check - - echo 'ROLE_PATH --> $ROLE_PATH' + - echo "ROLE_PATH --> '$ROLE_PATH'" ### ### STAGE-SYNTAX-CHECK @@ -101,68 +101,68 @@ syntax-oh-my-bash: - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH allow_failure: false -### -### STAGE-LINT-TESTS -### -lint-test: - stage: lint-tests - image: $IMAGE_NAME_LINT - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'test'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST - allow_failure: false +# ### +# ### STAGE-LINT-TESTS +# ### +# lint-test: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'test'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST +# allow_failure: false -lint-dependencies: - stage: lint-tests - image: $IMAGE_NAME_LINT - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'dependencies'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES - allow_failure: false +# lint-dependencies: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'dependencies'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES +# allow_failure: false -lint-clone-repositories: - stage: lint-tests - image: $IMAGE_NAME_LINT - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'clone_repositories'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES - allow_failure: false +# lint-clone-repositories: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'clone_repositories'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES +# allow_failure: false -lint-docker-images: - stage: lint-tests - image: $IMAGE_NAME_LINT - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'docker_images'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES - allow_failure: false +# lint-docker-images: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'docker_images'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES +# allow_failure: false -lint-docker-containers: - stage: lint-tests - image: $IMAGE_NAME_LINT - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'docker_containers'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS - allow_failure: false +# lint-docker-containers: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'docker_containers'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS +# allow_failure: false -lint-oh-my-bash: - stage: lint-tests - image: $IMAGE_NAME_LINT - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'docker_containers'" - - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH - allow_failure: false +# lint-oh-my-bash: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'docker_containers'" +# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH +# allow_failure: false # ### -- GitLab From 3d7078ad62dce3b5ec85dc898ef362e83de90f06 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 13:09:13 +0100 Subject: [PATCH 09/18] Refactoring CI-CD --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 308f29c..a5e2ddd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,6 +34,8 @@ stages: .run_syntax_check: &run_syntax_check - echo "ROLE_PATH --> '$ROLE_PATH'" + - echo "ansible-playbook --syntax-check -i $INVENTORIES_PATH $ROLE_PATH" + - ansible-playbook --syntax-check -i $INVENTORIES_PATH $ROLE_PATH ### ### STAGE-SYNTAX-CHECK @@ -47,7 +49,7 @@ syntax-test: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" - - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_TEST + # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_TEST - *run_syntax_check allow_failure: false -- GitLab From c3c14ea0a61dc4d6bb5da487505c134cf8aacc8d Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 13:36:37 +0100 Subject: [PATCH 10/18] Refactoring CI-CD --- .gitlab-ci.yml | 58 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a5e2ddd..87f8f4c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,10 +33,11 @@ stages: .run_syntax_check: &run_syntax_check - - echo "ROLE_PATH --> '$ROLE_PATH'" - - echo "ansible-playbook --syntax-check -i $INVENTORIES_PATH $ROLE_PATH" - ansible-playbook --syntax-check -i $INVENTORIES_PATH $ROLE_PATH +.run_lint: &run_lint + - ansible-lint $ROLE_PATH + ### ### STAGE-SYNTAX-CHECK ### @@ -49,72 +50,89 @@ syntax-test: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" - # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_TEST - *run_syntax_check allow_failure: false syntax-dependencies: stage: syntax-check image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES before_script: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'dependencies'" - - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES + # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES + - *run_syntax_check allow_failure: false syntax-clone-repositories: stage: syntax-check image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES before_script: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'clone_repositories'" - - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES + # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES + - *run_syntax_check allow_failure: false syntax-docker-images: stage: syntax-check image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES before_script: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_images'" - - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES + # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES + - *run_syntax_check allow_failure: false syntax-docker-containers: stage: syntax-check image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS before_script: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" - - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS + # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS + - *run_syntax_check allow_failure: false syntax-oh-my-bash: stage: syntax-check image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH before_script: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" - - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH + # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH + - *run_syntax_check allow_failure: false -# ### -# ### STAGE-LINT-TESTS -# ### -# lint-test: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'test'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST -# allow_failure: false +### +### STAGE-LINT-TESTS +### +lint-test: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'test'" + # - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST + - *run_lint + allow_failure: false # lint-dependencies: # stage: lint-tests -- GitLab From 346cebb206557f4c73598f43cf095e998fe3e0f6 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 13:46:20 +0100 Subject: [PATCH 11/18] Refactoring CI-CD --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 87f8f4c..1b24237 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,6 +36,10 @@ stages: - ansible-playbook --syntax-check -i $INVENTORIES_PATH $ROLE_PATH .run_lint: &run_lint + # Correct the permissions on the build environment directory. + # See https://github.com/ansible/ansible/pull/42142/files + # - chmod 700 /opt/atlassian/pipelines/agent/build + - chmod 700 /builds/fejao/c3infodesk-deployment - ansible-lint $ROLE_PATH ### -- GitLab From 8e509ed637c7551644b064dbf6410a3345b791b9 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 13:47:39 +0100 Subject: [PATCH 12/18] Refactoring CI-CD --- .gitlab-ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b24237..fceeadf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,11 +33,15 @@ stages: .run_syntax_check: &run_syntax_check + ### Correct the permissions on the build environment directory. + ### See https://github.com/ansible/ansible/pull/42142/files + # - chmod 700 /opt/atlassian/pipelines/agent/build + - chmod 700 /builds/fejao/c3infodesk-deployment - ansible-playbook --syntax-check -i $INVENTORIES_PATH $ROLE_PATH .run_lint: &run_lint - # Correct the permissions on the build environment directory. - # See https://github.com/ansible/ansible/pull/42142/files + ### Correct the permissions on the build environment directory. + ### See https://github.com/ansible/ansible/pull/42142/files # - chmod 700 /opt/atlassian/pipelines/agent/build - chmod 700 /builds/fejao/c3infodesk-deployment - ansible-lint $ROLE_PATH -- GitLab From bf0c7d3685e50bfcb4de8a12dbfe59e2012b2c96 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 13:51:09 +0100 Subject: [PATCH 13/18] Refactoring CI-CD --- .gitlab-ci.yml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fceeadf..4ac018a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,20 +30,23 @@ stages: .before_syntax_n_lint: &before_syntax_n_lint - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - pip3 install -r ci-cd/requirements.txt - - -.run_syntax_check: &run_syntax_check ### Correct the permissions on the build environment directory. ### See https://github.com/ansible/ansible/pull/42142/files - # - chmod 700 /opt/atlassian/pipelines/agent/build - chmod 700 /builds/fejao/c3infodesk-deployment + + +.run_syntax_check: &run_syntax_check + # ### Correct the permissions on the build environment directory. + # ### See https://github.com/ansible/ansible/pull/42142/files + # # - chmod 700 /opt/atlassian/pipelines/agent/build + # - chmod 700 /builds/fejao/c3infodesk-deployment - ansible-playbook --syntax-check -i $INVENTORIES_PATH $ROLE_PATH .run_lint: &run_lint - ### Correct the permissions on the build environment directory. - ### See https://github.com/ansible/ansible/pull/42142/files - # - chmod 700 /opt/atlassian/pipelines/agent/build - - chmod 700 /builds/fejao/c3infodesk-deployment + # ### Correct the permissions on the build environment directory. + # ### See https://github.com/ansible/ansible/pull/42142/files + # # - chmod 700 /opt/atlassian/pipelines/agent/build + # - chmod 700 /builds/fejao/c3infodesk-deployment - ansible-lint $ROLE_PATH ### @@ -70,7 +73,6 @@ syntax-dependencies: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'dependencies'" - # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES - *run_syntax_check allow_failure: false @@ -83,7 +85,6 @@ syntax-clone-repositories: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'clone_repositories'" - # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES - *run_syntax_check allow_failure: false @@ -96,7 +97,6 @@ syntax-docker-images: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_images'" - # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES - *run_syntax_check allow_failure: false @@ -109,7 +109,6 @@ syntax-docker-containers: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" - # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS - *run_syntax_check allow_failure: false @@ -122,7 +121,6 @@ syntax-oh-my-bash: - *before_syntax_n_lint script: - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" - # - ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH - *run_syntax_check allow_failure: false -- GitLab From 1474d2ee16c54d0f25c3e965f5c5e5f0e086a2c8 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 13:58:32 +0100 Subject: [PATCH 14/18] Refactoring CI-CD --- .gitlab-ci.yml | 134 ++++++++++++++++++++++++++++--------------------- 1 file changed, 76 insertions(+), 58 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ac018a..eba501b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,8 @@ variables: AUTHOR: fejao IMAGE_NAME_SYNTAX: python:3.10.15-bullseye IMAGE_NAME_LINT: python:3.10.15-bullseye - IMAGE_NAME_MOLECULE: geerlingguy/docker-ubuntu2204-ansible:latest + # IMAGE_NAME_MOLECULE: geerlingguy/docker-ubuntu2204-ansible:latest + IMAGE_NAME_MOLECULE: docker:dind INVENTORIES_PATH: "inventories/hosts" PLAYBOOK_PATH_FOR_ROLE_TEST: "ci-cd/01_test.yml" PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES: "ci-cd/02_dependencies.yml" @@ -36,17 +37,9 @@ stages: .run_syntax_check: &run_syntax_check - # ### Correct the permissions on the build environment directory. - # ### See https://github.com/ansible/ansible/pull/42142/files - # # - chmod 700 /opt/atlassian/pipelines/agent/build - # - chmod 700 /builds/fejao/c3infodesk-deployment - ansible-playbook --syntax-check -i $INVENTORIES_PATH $ROLE_PATH .run_lint: &run_lint - # ### Correct the permissions on the build environment directory. - # ### See https://github.com/ansible/ansible/pull/42142/files - # # - chmod 700 /opt/atlassian/pipelines/agent/build - # - chmod 700 /builds/fejao/c3infodesk-deployment - ansible-lint $ROLE_PATH ### @@ -136,64 +129,89 @@ lint-test: - *before_syntax_n_lint script: - echo "Running ansible-lint tests at the role-> 'test'" - # - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST - *run_lint allow_failure: false -# lint-dependencies: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'dependencies'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES -# allow_failure: false +lint-dependencies: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'dependencies'" + - *run_lint + allow_failure: false -# lint-clone-repositories: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'clone_repositories'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES -# allow_failure: false +lint-clone-repositories: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'clone_repositories'" + - *run_lint + allow_failure: false -# lint-docker-images: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'docker_images'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES -# allow_failure: false +lint-docker-images: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'docker_images'" + - *run_lint + allow_failure: false -# lint-docker-containers: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'docker_containers'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS -# allow_failure: false +lint-docker-containers: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'docker_containers'" + - *run_lint + allow_failure: false + +lint-oh-my-bash: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'docker_containers'" + - *run_lint + allow_failure: false -# lint-oh-my-bash: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'docker_containers'" -# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH -# allow_failure: false +### +### STAGE-MOLECULE +### +molecule-test: + stage: molecule + image: $IMAGE_NAME_MOLECULE + # before_script: + # # - apk add --no-cache python3 py3-pip + # # - rm /usr/lib/python*/EXTERNALLY-MANAGED + # # - python3 -m ensurepip + # - pip3 install ansible ansible-lint molecule molecule-docker + # - pip3 install --user "molecule-plugins[docker]" + script: + - echo "Running molecule tests at the role-> 'test'" + - docker ps -a + # - cd roles/test + # - molecule test + allow_failure: false -# ### -# ### STAGE-MOLECULE -# ### # molecule-test: # stage: molecule # # image: docker:latest -- GitLab From 9f50491a22f48d1cdc6397205fc9bfa26c384d0c Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 14:07:20 +0100 Subject: [PATCH 15/18] Test setting DIND --- .gitlab-ci.yml | 279 +++++++++++++++++++++++++------------------------ 1 file changed, 140 insertions(+), 139 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eba501b..7703aa8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,162 +35,161 @@ stages: ### See https://github.com/ansible/ansible/pull/42142/files - chmod 700 /builds/fejao/c3infodesk-deployment - .run_syntax_check: &run_syntax_check - ansible-playbook --syntax-check -i $INVENTORIES_PATH $ROLE_PATH .run_lint: &run_lint - ansible-lint $ROLE_PATH -### -### STAGE-SYNTAX-CHECK -### -syntax-test: - stage: syntax-check - image: $IMAGE_NAME_SYNTAX - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" - - *run_syntax_check - allow_failure: false +# ### +# ### STAGE-SYNTAX-CHECK +# ### +# syntax-test: +# stage: syntax-check +# image: $IMAGE_NAME_SYNTAX +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" +# - *run_syntax_check +# allow_failure: false -syntax-dependencies: - stage: syntax-check - image: $IMAGE_NAME_SYNTAX - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-playbook --syntax-check tests at the role-> 'dependencies'" - - *run_syntax_check - allow_failure: false +# syntax-dependencies: +# stage: syntax-check +# image: $IMAGE_NAME_SYNTAX +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-playbook --syntax-check tests at the role-> 'dependencies'" +# - *run_syntax_check +# allow_failure: false -syntax-clone-repositories: - stage: syntax-check - image: $IMAGE_NAME_SYNTAX - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-playbook --syntax-check tests at the role-> 'clone_repositories'" - - *run_syntax_check - allow_failure: false +# syntax-clone-repositories: +# stage: syntax-check +# image: $IMAGE_NAME_SYNTAX +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-playbook --syntax-check tests at the role-> 'clone_repositories'" +# - *run_syntax_check +# allow_failure: false -syntax-docker-images: - stage: syntax-check - image: $IMAGE_NAME_SYNTAX - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_images'" - - *run_syntax_check - allow_failure: false +# syntax-docker-images: +# stage: syntax-check +# image: $IMAGE_NAME_SYNTAX +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_images'" +# - *run_syntax_check +# allow_failure: false -syntax-docker-containers: - stage: syntax-check - image: $IMAGE_NAME_SYNTAX - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" - - *run_syntax_check - allow_failure: false +# syntax-docker-containers: +# stage: syntax-check +# image: $IMAGE_NAME_SYNTAX +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" +# - *run_syntax_check +# allow_failure: false -syntax-oh-my-bash: - stage: syntax-check - image: $IMAGE_NAME_SYNTAX - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" - - *run_syntax_check - allow_failure: false +# syntax-oh-my-bash: +# stage: syntax-check +# image: $IMAGE_NAME_SYNTAX +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" +# - *run_syntax_check +# allow_failure: false -### -### STAGE-LINT-TESTS -### -lint-test: - stage: lint-tests - image: $IMAGE_NAME_LINT - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'test'" - - *run_lint - allow_failure: false +# ### +# ### STAGE-LINT-TESTS +# ### +# lint-test: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'test'" +# - *run_lint +# allow_failure: false -lint-dependencies: - stage: lint-tests - image: $IMAGE_NAME_LINT - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'dependencies'" - - *run_lint - allow_failure: false +# lint-dependencies: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'dependencies'" +# - *run_lint +# allow_failure: false -lint-clone-repositories: - stage: lint-tests - image: $IMAGE_NAME_LINT - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'clone_repositories'" - - *run_lint - allow_failure: false +# lint-clone-repositories: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'clone_repositories'" +# - *run_lint +# allow_failure: false -lint-docker-images: - stage: lint-tests - image: $IMAGE_NAME_LINT - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'docker_images'" - - *run_lint - allow_failure: false +# lint-docker-images: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'docker_images'" +# - *run_lint +# allow_failure: false -lint-docker-containers: - stage: lint-tests - image: $IMAGE_NAME_LINT - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'docker_containers'" - - *run_lint - allow_failure: false +# lint-docker-containers: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'docker_containers'" +# - *run_lint +# allow_failure: false -lint-oh-my-bash: - stage: lint-tests - image: $IMAGE_NAME_LINT - variables: - ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH - before_script: - - *before_syntax_n_lint - script: - - echo "Running ansible-lint tests at the role-> 'docker_containers'" - - *run_lint - allow_failure: false +# lint-oh-my-bash: +# stage: lint-tests +# image: $IMAGE_NAME_LINT +# variables: +# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH +# before_script: +# - *before_syntax_n_lint +# script: +# - echo "Running ansible-lint tests at the role-> 'docker_containers'" +# - *run_lint +# allow_failure: false ### @@ -199,6 +198,8 @@ lint-oh-my-bash: molecule-test: stage: molecule image: $IMAGE_NAME_MOLECULE + tags: + - saas-linux-small-amd64 # before_script: # # - apk add --no-cache python3 py3-pip # # - rm /usr/lib/python*/EXTERNALLY-MANAGED -- GitLab From c11cabf2e9fdb03bb7e1113e45c02bd4b3c9ee2a Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 14:35:23 +0100 Subject: [PATCH 16/18] Setting DIND --- .gitlab-ci.yml | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7703aa8..f98c257 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,11 +195,19 @@ stages: ### ### STAGE-MOLECULE ### -molecule-test: - stage: molecule - image: $IMAGE_NAME_MOLECULE - tags: - - saas-linux-small-amd64 +dind-test: + stage: debug + # image: $IMAGE_NAME_MOLECULE + # image: docker:dind + image: docker:27.5.1 + services: + - docker:27.5.1-dind + ### AVAILABLE TAGS + # https://docs.gitlab.com/ee/ci/runners/hosted_runners/linux.html#machine-types-available-for-linux---x86-64 + # tags: + # - saas-linux-small-amd64 + before_script: + - docker info # before_script: # # - apk add --no-cache python3 py3-pip # # - rm /usr/lib/python*/EXTERNALLY-MANAGED @@ -213,6 +221,29 @@ molecule-test: # - molecule test allow_failure: false + + + +# molecule-test: +# stage: molecule +# image: $IMAGE_NAME_MOLECULE +# ### AVAILABLE TAGS +# # https://docs.gitlab.com/ee/ci/runners/hosted_runners/linux.html#machine-types-available-for-linux---x86-64 +# tags: +# - saas-linux-small-amd64 +# # before_script: +# # # - apk add --no-cache python3 py3-pip +# # # - rm /usr/lib/python*/EXTERNALLY-MANAGED +# # # - python3 -m ensurepip +# # - pip3 install ansible ansible-lint molecule molecule-docker +# # - pip3 install --user "molecule-plugins[docker]" +# script: +# - echo "Running molecule tests at the role-> 'test'" +# - docker ps -a +# # - cd roles/test +# # - molecule test +# allow_failure: false + # molecule-test: # stage: molecule # # image: docker:latest -- GitLab From c1435930b5ecb48657207f07b8a7f821e090d273 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Sat, 8 Feb 2025 14:37:09 +0100 Subject: [PATCH 17/18] Setting DIND --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f98c257..20ee853 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -196,7 +196,8 @@ stages: ### STAGE-MOLECULE ### dind-test: - stage: debug + # stage: debug + stage: molecule # image: $IMAGE_NAME_MOLECULE # image: docker:dind image: docker:27.5.1 -- GitLab From 803fb9fb2e096d98ec7ff0f2d4ac126f18109a20 Mon Sep 17 00:00:00 2001 From: fejao <mail@fejao.de> Date: Tue, 11 Feb 2025 10:28:24 +0100 Subject: [PATCH 18/18] last file updates --- .gitignore | 1 + .gitlab-ci.yml | 306 ++++++++++------------- roles/test/molecule/default/converge.yml | 6 +- 3 files changed, 143 insertions(+), 170 deletions(-) diff --git a/.gitignore b/.gitignore index e975424..617b129 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *OLD* *DONT_PUSH* *notes* +*.vscode* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20ee853..7111d1b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,190 +41,160 @@ stages: .run_lint: &run_lint - ansible-lint $ROLE_PATH -# ### -# ### STAGE-SYNTAX-CHECK -# ### -# syntax-test: -# stage: syntax-check -# image: $IMAGE_NAME_SYNTAX -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" -# - *run_syntax_check -# allow_failure: false - -# syntax-dependencies: -# stage: syntax-check -# image: $IMAGE_NAME_SYNTAX -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-playbook --syntax-check tests at the role-> 'dependencies'" -# - *run_syntax_check -# allow_failure: false - -# syntax-clone-repositories: -# stage: syntax-check -# image: $IMAGE_NAME_SYNTAX -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-playbook --syntax-check tests at the role-> 'clone_repositories'" -# - *run_syntax_check -# allow_failure: false - -# syntax-docker-images: -# stage: syntax-check -# image: $IMAGE_NAME_SYNTAX -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_images'" -# - *run_syntax_check -# allow_failure: false - -# syntax-docker-containers: -# stage: syntax-check -# image: $IMAGE_NAME_SYNTAX -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" -# - *run_syntax_check -# allow_failure: false +### +### STAGE-SYNTAX-CHECK +### +syntax-test: + stage: syntax-check + image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" + - *run_syntax_check + allow_failure: false -# syntax-oh-my-bash: -# stage: syntax-check -# image: $IMAGE_NAME_SYNTAX -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" -# - *run_syntax_check -# allow_failure: false +syntax-dependencies: + stage: syntax-check + image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-playbook --syntax-check tests at the role-> 'dependencies'" + - *run_syntax_check + allow_failure: false -# ### -# ### STAGE-LINT-TESTS -# ### -# lint-test: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'test'" -# - *run_lint -# allow_failure: false +syntax-clone-repositories: + stage: syntax-check + image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-playbook --syntax-check tests at the role-> 'clone_repositories'" + - *run_syntax_check + allow_failure: false -# lint-dependencies: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'dependencies'" -# - *run_lint -# allow_failure: false +syntax-docker-images: + stage: syntax-check + image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_images'" + - *run_syntax_check + allow_failure: false -# lint-clone-repositories: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'clone_repositories'" -# - *run_lint -# allow_failure: false +syntax-docker-containers: + stage: syntax-check + image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" + - *run_syntax_check + allow_failure: false -# lint-docker-images: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'docker_images'" -# - *run_lint -# allow_failure: false +syntax-oh-my-bash: + stage: syntax-check + image: $IMAGE_NAME_SYNTAX + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" + - *run_syntax_check + allow_failure: false -# lint-docker-containers: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'docker_containers'" -# - *run_lint -# allow_failure: false +### +### STAGE-LINT-TESTS +### +lint-test: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'test'" + - *run_lint + allow_failure: false -# lint-oh-my-bash: -# stage: lint-tests -# image: $IMAGE_NAME_LINT -# variables: -# ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH -# before_script: -# - *before_syntax_n_lint -# script: -# - echo "Running ansible-lint tests at the role-> 'docker_containers'" -# - *run_lint -# allow_failure: false +lint-dependencies: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'dependencies'" + - *run_lint + allow_failure: false +lint-clone-repositories: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'clone_repositories'" + - *run_lint + allow_failure: false -### -### STAGE-MOLECULE -### -dind-test: - # stage: debug - stage: molecule - # image: $IMAGE_NAME_MOLECULE - # image: docker:dind - image: docker:27.5.1 - services: - - docker:27.5.1-dind - ### AVAILABLE TAGS - # https://docs.gitlab.com/ee/ci/runners/hosted_runners/linux.html#machine-types-available-for-linux---x86-64 - # tags: - # - saas-linux-small-amd64 +lint-docker-images: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES before_script: - - docker info - # before_script: - # # - apk add --no-cache python3 py3-pip - # # - rm /usr/lib/python*/EXTERNALLY-MANAGED - # # - python3 -m ensurepip - # - pip3 install ansible ansible-lint molecule molecule-docker - # - pip3 install --user "molecule-plugins[docker]" + - *before_syntax_n_lint script: - - echo "Running molecule tests at the role-> 'test'" - - docker ps -a - # - cd roles/test - # - molecule test + - echo "Running ansible-lint tests at the role-> 'docker_images'" + - *run_lint allow_failure: false +lint-docker-containers: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'docker_containers'" + - *run_lint + allow_failure: false +lint-oh-my-bash: + stage: lint-tests + image: $IMAGE_NAME_LINT + variables: + ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH + before_script: + - *before_syntax_n_lint + script: + - echo "Running ansible-lint tests at the role-> 'docker_containers'" + - *run_lint + allow_failure: false +### +### STAGE-MOLECULE --> At the moment, running DIND (docker in docker) at this instance is disable :( +### # molecule-test: # stage: molecule # image: $IMAGE_NAME_MOLECULE diff --git a/roles/test/molecule/default/converge.yml b/roles/test/molecule/default/converge.yml index 7cbd7c0..9aa3642 100644 --- a/roles/test/molecule/default/converge.yml +++ b/roles/test/molecule/default/converge.yml @@ -1,5 +1,7 @@ --- - name: MOLECULE | Converge hosts: all - roles: - - role: test + tasks: + - name: MOLECULE | CONVERGE | Call the 'test' role. + ansible.builtin.include_role: + name: test -- GitLab