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

Updated ci-cd

parent 1b3a9dd2
No related branches found
No related tags found
1 merge request!10Added molecule tests for 'test' role
Pipeline #37418 passed
...@@ -17,143 +17,143 @@ stages: ...@@ -17,143 +17,143 @@ stages:
- lint-tests - lint-tests
- molecule - molecule
# ### ###
# ### SYNTAX-CHECK ### SYNTAX-CHECK
# ### ###
# syntax-test: syntax-test:
# stage: syntax-check stage: syntax-check
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-playbook --syntax-check tests at the role-> 'test'" - 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
# allow_failure: false allow_failure: false
# syntax-dependencies: syntax-dependencies:
# stage: syntax-check stage: syntax-check
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-playbook --syntax-check tests at the role-> 'dependencies'" - 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
# allow_failure: false allow_failure: false
# syntax-clone-repositories: syntax-clone-repositories:
# stage: syntax-check stage: syntax-check
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-playbook --syntax-check tests at the role-> 'clone_repositories'" - 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
# allow_failure: false allow_failure: false
# syntax-docker-images: syntax-docker-images:
# stage: syntax-check stage: syntax-check
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_images'" - 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
# allow_failure: false allow_failure: false
# syntax-docker-containers: syntax-docker-containers:
# stage: syntax-check stage: syntax-check
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-playbook --syntax-check tests at the role-> 'docker_containers'" - 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
# allow_failure: false allow_failure: false
# ### ###
# ### LINT-TESTS ### LINT-TESTS
# ### ###
# lint-test: lint-test:
# stage: lint-tests stage: lint-tests
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-lint tests at the role-> 'test'" - echo "Running ansible-lint tests at the role-> 'test'"
# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_TEST
# allow_failure: false allow_failure: false
# lint-dependencies: lint-dependencies:
# stage: lint-tests stage: lint-tests
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-lint tests at the role-> 'dependencies'" - echo "Running ansible-lint tests at the role-> 'dependencies'"
# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DEPENDENCIES
# allow_failure: false allow_failure: false
# lint-clone-repositories: lint-clone-repositories:
# stage: lint-tests stage: lint-tests
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-lint tests at the role-> 'clone_repositories'" - echo "Running ansible-lint tests at the role-> 'clone_repositories'"
# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_CLONE_REPOSITORIES
# allow_failure: false allow_failure: false
# lint-docker-images: lint-docker-images:
# stage: lint-tests stage: lint-tests
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-lint tests at the role-> 'docker_images'" - echo "Running ansible-lint tests at the role-> 'docker_images'"
# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_IMAGES
# allow_failure: false allow_failure: false
# lint-docker-containers: lint-docker-containers:
# stage: lint-tests stage: lint-tests
# image: python:3.10.15-bullseye image: python:3.10.15-bullseye
# before_script: before_script:
# - apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/* - 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 - pip3 install -r ci-cd/requirements.txt
# script: script:
# - echo "Running ansible-lint tests at the role-> 'docker_containers'" - echo "Running ansible-lint tests at the role-> 'docker_containers'"
# - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS - ansible-lint $PLAYBOOK_PATH_FOR_ROLE_DOCKER_CONTAINERS
# allow_failure: false allow_failure: false
### ###
### molecule ### molecule
### ###
molecule-test: # molecule-test:
stage: molecule # stage: molecule
# image: docker:latest # # image: docker:latest
# image: docker:27.5.1-alpine3.21 # # image: docker:27.5.1-alpine3.21
image: docker:27.5.1-dind # image: docker:27.5.1-dind
before_script: # before_script:
- apk add --no-cache python3 py3-pip # - apk add --no-cache python3 py3-pip
- rm /usr/lib/python*/EXTERNALLY-MANAGED # - rm /usr/lib/python*/EXTERNALLY-MANAGED
- python3 -m ensurepip # - python3 -m ensurepip
- pip3 install ansible ansible-lint molecule molecule-docker # - pip3 install ansible ansible-lint molecule molecule-docker
- pip3 install --user "molecule-plugins[docker]" # - pip3 install --user "molecule-plugins[docker]"
script: # script:
- echo "Running ansible-lint tests at the role-> 'test'" # - echo "Running ansible-lint tests at the role-> 'test'"
- docker ps -a # - docker ps -a
- cd roles/test # - cd roles/test
- molecule test # - molecule test
allow_failure: false # allow_failure: false
# molecule-test: # molecule-test:
# stage: molecule # stage: molecule
......
# test role # test role
This is a ansible-role for testing your installed ansible. This is a ansible-role for testing your installed ansible.
## Requirements ## Requirements
To have ansible installed at your system. To have ansible installed at your system.
## Role Variables ## Role Variables
You should look around where the variables are setted. And figure it out from where the ouput comes You should look around where the variables are setted. And figure it out from where the ouput comes
## Dependencies ## Dependencies
This role have no dependency from any another role. This role have no dependency from any another role.
## Example Playbook ## Example Playbook
Here is an example for adding this role for your playbook for **restarting** the **c3infodesk-printer**. containers: Here is an example for adding this role for your playbook for **restarting** the **c3infodesk-printer**. containers:
...@@ -27,10 +30,32 @@ And call the playbook as: ...@@ -27,10 +30,32 @@ And call the playbook as:
ansible-playbook -i <INVENTORY> <PLAYBOOK_NAME>.yml ansible-playbook -i <INVENTORY> <PLAYBOOK_NAME>.yml
``` ```
## Tests
Here are the tests made at **CI-CD** for this role.
The tests shuold be runned at the root directory from the repository.
### Syntax
```bash
ansible-playbook --syntax-check -i invenvories/hosts ci-cd/01_test.yml
```
### Lint
```bash
ansible-lint ci-cd/01_test.yml
```
### molecule
```bash
cd roles/test
molecule test
```
## License ## License
MIT/BSD MIT/BSD
## Author Information ## Author Information
![fejao logo](../../files/from_authors/fejao_logo_circle.png "fejao") [https://chaos.social/@fejao](https://chaos.social/@fejao) ![fejao logo](../../files/from_authors/fejao_logo_circle.png "fejao") [https://chaos.social/@fejao](https://chaos.social/@fejao)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment