Skip to content
Snippets Groups Projects
Commit b8a4d5f8 authored by fejao's avatar fejao
Browse files

Merge branch 'Setting_CI_CD_molecule' into 'main'

Setting ci cd molecule

See merge request !16
parents 6bf23eb4 feed502b
No related branches found
No related tags found
1 merge request!16Setting ci cd molecule
Pipeline #37678 canceled
*OLD*
*DONT_PUSH*
*notes*
*.vscode*
# 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
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"
......@@ -13,169 +17,222 @@ 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
- molecule
###
### SYNTAX-CHECK
### 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
### Correct the permissions on the build environment directory.
### 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: python:3.10.15-bullseye
image: $IMAGE_NAME_SYNTAX
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST
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'"
- ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH_FOR_ROLE_TEST
- *run_syntax_check
allow_failure: false
syntax-dependencies:
stage: syntax-check
image: python:3.10.15-bullseye
image: $IMAGE_NAME_SYNTAX
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES
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
- *run_syntax_check
allow_failure: false
syntax-clone-repositories:
stage: syntax-check
image: python:3.10.15-bullseye
image: $IMAGE_NAME_SYNTAX
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES
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
- *run_syntax_check
allow_failure: false
syntax-docker-images:
stage: syntax-check
image: python:3.10.15-bullseye
image: $IMAGE_NAME_SYNTAX
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES
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
- *run_syntax_check
allow_failure: false
syntax-docker-containers:
stage: syntax-check
image: python:3.10.15-bullseye
image: $IMAGE_NAME_SYNTAX
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS
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
- *run_syntax_check
allow_failure: false
syntax-oh-my-bash:
stage: syntax-check
image: python:3.10.15-bullseye
image: $IMAGE_NAME_SYNTAX
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH
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
- *run_syntax_check
allow_failure: false
###
### LINT-TESTS
### STAGE-LINT-TESTS
###
lint-test:
stage: lint-tests
image: python:3.10.15-bullseye
image: $IMAGE_NAME_LINT
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_TEST
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-lint tests at the role-> 'test'"
- ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST
- *run_lint
allow_failure: false
lint-dependencies:
stage: lint-tests
image: python:3.10.15-bullseye
image: $IMAGE_NAME_LINT
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES
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-lint tests at the role-> 'dependencies'"
- ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES
- *run_lint
allow_failure: false
lint-clone-repositories:
stage: lint-tests
image: python:3.10.15-bullseye
image: $IMAGE_NAME_LINT
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES
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-lint tests at the role-> 'clone_repositories'"
- ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES
- *run_lint
allow_failure: false
lint-docker-images:
stage: lint-tests
image: python:3.10.15-bullseye
image: $IMAGE_NAME_LINT
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES
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-lint tests at the role-> 'docker_images'"
- ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES
- *run_lint
allow_failure: false
lint-docker-containers:
stage: lint-tests
image: python:3.10.15-bullseye
image: $IMAGE_NAME_LINT
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS
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-lint tests at the role-> 'docker_containers'"
- ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS
- *run_lint
allow_failure: false
lint-oh-my-bash:
stage: lint-tests
image: python:3.10.15-bullseye
image: $IMAGE_NAME_LINT
variables:
ROLE_PATH: $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH
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-lint tests at the role-> 'docker_containers'"
- ansible-lint $PLAYBOOK_PATH_FOR_ROLE_OH_MY_BASH
- *run_lint
allow_failure: false
###
### molecule
### STAGE-MOLECULE --> At the moment, running DIND (docker in docker) at this instance is disable :(
###
# 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
# # image: docker:27.5.1-alpine3.21
# image: docker:27.5.1-dind
# # 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
# # - 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
# # - cd roles/test
# # - molecule test
# allow_failure: false
# molecule-test:
......
......@@ -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?
......
# clone-repositories role
# clone_repositories role
This ansible-role for dealing with cloning the repositories necessary for deploying the system used from **c3infodesk**.
......
......@@ -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
......
......@@ -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"
......
---
- name: MOLECULE | Converge
hosts: all
roles:
- role: test
tasks:
- name: MOLECULE | CONVERGE | Call the 'test' role.
ansible.builtin.include_role:
name: test
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment