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

Merge branch 'Adding_ci_cd_triggers' into 'main'

Adding ci cd triggers

See merge request !18
parents ead0f3b5 e8a85b8a
No related branches found
No related tags found
1 merge request!18Adding ci cd triggers
Pipeline #37758 passed
---
# image: python:3.10.15-bullseye
###
### VARIABLES
###
variables:
AUTHOR: fejao
### IMAGES
IMAGE_NAME_SYNTAX: python:3.10.15-bullseye
IMAGE_NAME_LINT: python:3.10.15-bullseye
IMAGE_NAME_MOLECULE: python:3.10.15-bullseye
# IMAGE_NAME_MOLECULE: geerlingguy/docker-ubuntu2204-ansible:latest
### PATHS
INVENTORIES_PATH: "inventories/hosts"
PATH_INVENTORIES: "inventories/hosts"
PATH_REQUIREMENTS_SYNTAX_N_LINT: "ci-cd/python_requirements/requirements_syntax_n_lint.txt"
PATH_ENV_DIR_DEPLOYMENT: "/builds/fejao/c3infodesk-deployment"
### PATHS
# INVENTORIES_PATH: "inventories/hosts"
PATH_PLAYBOOK_FOR_ROLE_TEST: "ci-cd/playbooks/01_test.yml"
PATH_PLAYBOOK_FOR_ROLE_DEPENDENCIES: "ci-cd/playbooks/02_dependencies.yml"
PATH_PLAYBOOK_FOR_ROLE_CLONE_REPOSITORIES: "ci-cd/playbooks/03_clone_repositories.yml"
......@@ -24,7 +27,7 @@ variables:
### STAGES
###
stages:
- before-role-trigger
- debug-variables
- syntax-checks
- lint-tests
- molecule
......@@ -33,7 +36,42 @@ stages:
### TEMPLATES
###
include:
# - local: ci-cd/templates/trigger-pipeline.yml
- local: ci-cd/templates/syntax-checks.yml
- local: ci-cd/templates/lint-tests.yml
- local: ci-cd/templates/molecule.yml
### ROLE TEST
- local: ci-cd/templates/role-test.yml
rules:
- if: '$RUN_UPSTREAM_FOR_ROLE_TEST == "true"'
### ROLE DEPENDENCIES
- local: ci-cd/templates/role-dependencies.yml
rules:
- if: '$RUN_UPSTREAM_FOR_ROLE_DEPENDENCIES == "true"'
### ROLE CLONE-REPOSITORIES
- local: ci-cd/templates/role-clone-repositories.yml
rules:
- if: '$RUN_UPSTREAM_FOR_ROLE_CLONE_REPOSITORIES == "true"'
### ROLE DOCKER-IMAGES
- local: ci-cd/templates/role-docker-images.yml
rules:
- if: '$RUN_UPSTREAM_FOR_ROLE_DOCKER_IMAGES == "true"'
### ROLE DOCKER-CONTAINERS
- local: ci-cd/templates/role-docker-containers.yml
rules:
- if: '$RUN_UPSTREAM_FOR_ROLE_DOCKER_CONTAINERS == "true"'
### ROLE OH-MY-BASH
- local: ci-cd/templates/role-oh-my-bash.yml
rules:
- if: '$RUN_UPSTREAM_FOR_ROLE_OH_MY_BASH == "true"'
###
### TEST PARSED VARS FROM UPSTREAM
###
variables-debug:
stage: debug-variables
image: $IMAGE_NAME_SYNTAX
script:
- echo "Testing the parsed variables from up-stream..."
- echo "RUN_UPSTREAM_FOR_ROLE_TEST --> $RUN_UPSTREAM_FOR_ROLE_TEST"
- echo "RUN_UPSTREAM_FOR_ROLE_DEPENDENCIES --> $RUN_UPSTREAM_FOR_ROLE_DEPENDENCIES"
- echo "RUN_UPSTREAM_FOR_ROLE_CLONE_REPOSITORIES --> $RUN_UPSTREAM_FOR_ROLE_CLONE_REPOSITORIES"
- echo "RUN_UPSTREAM_FOR_ROLE_DOCKER_IMAGES --> $RUN_UPSTREAM_FOR_ROLE_DOCKER_IMAGES"
- echo "RUN_UPSTREAM_FOR_ROLE_DOCKER_CONTAINERS --> $RUN_UPSTREAM_FOR_ROLE_DOCKER_CONTAINERS"
- echo "RUN_UPSTREAM_FOR_ROLE_OH_MY_BASH --> $RUN_UPSTREAM_FOR_ROLE_OH_MY_BASH"
---
variables:
INVENTORIES_PATH: "inventories/hosts"
REQUIREMENTS_PATH: "ci-cd/python_requirements/requirements_syntax_n_lint.txt"
ENV_DIR_PATH: "/builds/fejao/c3infodesk-deployment"
AUTHOR: fejao
###
### SCRIPTS
......@@ -12,17 +10,16 @@ variables:
before_script:
- echo "Running before_script for 'before_script_syntax_n_lint'"
- apt-get update && apt-get install -y python3-pip && apt-get clean && rm -rf /var/lib/apt/lists/*
- pip3 install -r $REQUIREMENTS_PATH
###########
- pip3 install -r $PATH_REQUIREMENTS_SYNTAX_N_LINT
# ### Correct the permissions on the build environment directory.
# ### See https://github.com/ansible/ansible/pull/42142/files
- chmod 700 $ENV_DIR_PATH
- chmod 700 $PATH_ENV_DIR_DEPLOYMENT
.script_syntax_check_main:
extends: .before_script_syntax_n_lint
script:
- echo "Running script for 'script_syntax_check_main'"
- ansible-playbook --syntax-check -i $INVENTORIES_PATH $PLAYBOOK_PATH
- ansible-playbook --syntax-check -i $PATH_INVENTORIES $PLAYBOOK_PATH
.run_lint:
extends: .before_script_syntax_n_lint
......
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
###
### INCLUDE
###
include:
- local: /ci-cd/scripts/syntax_n_lint.yml
###
### STAGE-LINT-TESTS
###
lint-test:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_TEST
# only:
# changes:
# - roles/c3infodesk-deployment-role-test
lint-dependencies:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DEPENDENCIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-dependencies
lint-clone-repositories:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_CLONE_REPOSITORIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-clone-repositories
lint-docker-images:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DOCKER_IMAGES
# only:
# changes:
# - roles/c3infodesk-deployment-role-docker-containers
lint-docker-containers:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DOCKER_CONTAINERS
# only:
# changes:
# - roles/c3infodesk-deployment-role-docker-containers
lint-oh-my-bash:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_OH_MY_BASH
# only:
# changes:
# - roles/c3infodesk-deployment-role-oh-my-bash
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
molecule-not-enabled:
stage: molecule
image: $IMAGE_NAME_MOLECULE
script:
- echo "This can't be done before enable DIND at the instance"
###
### 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: 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
# # image: docker:latest
# image: docker:27.5.1-alpine3.21
# 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
# - pip3 install --upgrade molecule molecule-docker
# # - python3 -m pip install --user "molecule-plugins[docker]
# - pip3 install --user "molecule-plugins[docker]"
# script:
# - echo "Running ansible-lint tests at the role-> 'test'"
# - cd roles/test
# - molecule test
# allow_failure: false
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
###
### INCLUDE
###
include:
- local: /ci-cd/scripts/syntax_n_lint.yml
###
### SYNTAX
###
syntax-clone-repositories:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_CLONE_REPOSITORIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-clone-repositories
###
### LINT
###
lint-clone-repositories:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_CLONE_REPOSITORIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-clone-repositories
###
### MOLECULE
###
molecule-dependencies:
stage: molecule
image: $IMAGE_NAME_MOLECULE
script:
- echo "This can't be done before enable DIND at the instance"
only:
refs:
- main
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
###
### INCLUDE
###
include:
- local: /ci-cd/scripts/syntax_n_lint.yml
###
### SYNTAX
###
syntax-dependencies:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DEPENDENCIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-dependencies
###
### LINT
###
lint-dependencies:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DEPENDENCIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-dependencies
###
### MOLECULE
###
molecule-dependencies:
stage: molecule
image: $IMAGE_NAME_MOLECULE
script:
- echo "This can't be done before enable DIND at the instance"
only:
refs:
- main
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
###
### INCLUDE
###
include:
- local: /ci-cd/scripts/syntax_n_lint.yml
###
### SYNTAX
###
syntax-clone-repositories:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DOCKER_CONTAINERS
# only:
# changes:
# - roles/c3infodesk-deployment-role-clone-repositories
###
### LINT
###
lint-clone-repositories:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DOCKER_CONTAINERS
# only:
# changes:
# - roles/c3infodesk-deployment-role-clone-repositories
###
### MOLECULE
###
molecule-docker-containers:
stage: molecule
image: $IMAGE_NAME_MOLECULE
script:
- echo "This can't be done before enable DIND at the instance"
only:
refs:
- main
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
###
### INCLUDE
###
include:
- local: /ci-cd/scripts/syntax_n_lint.yml
###
### SYNTAX
###
syntax-docker-images:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DOCKER_IMAGES
# only:
# changes:
# - roles/c3infodesk-deployment-role-docker-images
###
### LINT
###
lint-docker-images:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DOCKER_IMAGES
# only:
# changes:
# - roles/c3infodesk-deployment-role-docker-containers
###
### MOLECULE
###
molecule-docker-images:
stage: molecule
image: $IMAGE_NAME_MOLECULE
script:
- echo "This can't be done before enable DIND at the instance"
only:
refs:
- main
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
###
### INCLUDE
###
include:
- local: /ci-cd/scripts/syntax_n_lint.yml
###
### SYNTAX
###
syntax-clone-repositories:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_CLONE_REPOSITORIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-clone-repositories
###
### LINT
###
lint-clone-repositories:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_CLONE_REPOSITORIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-clone-repositories
###
### MOLECULE
###
molecule-oh-my-bash:
stage: molecule
image: $IMAGE_NAME_MOLECULE
script:
- echo "This can't be done before enable DIND at the instance"
only:
refs:
- main
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
###
### INCLUDE
###
include:
- local: /ci-cd/scripts/syntax_n_lint.yml
###
### SYNTAX
###
syntax-test:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_TEST
# only:
# changes:
# - roles/c3infodesk-deployment-role-test
###
### LINT
###
lint-test:
stage: lint-tests
image: $IMAGE_NAME_LINT
extends: .run_lint
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_TEST
# only:
# changes:
# - roles/c3infodesk-deployment-role-test
###
### MOLECULE
###
molecule-test:
stage: molecule
image: $IMAGE_NAME_MOLECULE
script:
- echo "This can't be done before enable DIND at the instance"
only:
refs:
- main
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
###
### INCLUDE
###
include:
- local: /ci-cd/scripts/syntax_n_lint.yml
###
### STAGE-SYNTAX-CHECKS
###
syntax-test:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_TEST
# only:
# changes:
# - roles/c3infodesk-deployment-role-test
# refs:
# - main
syntax-dependencies:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DEPENDENCIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-dependencies
syntax-clone-repositories:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_CLONE_REPOSITORIES
# only:
# changes:
# - roles/c3infodesk-deployment-role-clone-repositories
syntax-docker-images:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DOCKER_IMAGES
# only:
# changes:
# - roles/c3infodesk-deployment-role-docker-images
syntax-docker-containers:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_DOCKER_CONTAINERS
# only:
# changes:
# - roles/c3infodesk-deployment-role-docker-containers
syntax-oh-my-bash:
stage: syntax-checks
image: $IMAGE_NAME_SYNTAX
extends: .script_syntax_check_main
variables:
PLAYBOOK_PATH: $PATH_PLAYBOOK_FOR_ROLE_OH_MY_BASH
# only:
# changes:
# - roles/c3infodesk-deployment-role-oh-my-bash
---
###
### VARIABLES
###
variables:
AUTHOR: fejao
trigger-pipeline:
stage: before-role-trigger
# trigger:
# include: <ChildFolder>/.gitlab-ci.yml
# trigger:
# # include: roles/c3infodesk-deployment-role-test/.gitlab-ci.yml
# include: /builds/fejao/c3infodesk-deployment/roles/c3infodesk-deployment-role-test/.gitlab-ci.yml
script:
- echo "Triggering tests for the 'test' role"
- pwd
# /builds/fejao/c3infodesk-deployment
- ls -la
- ls -la roles
- ls -la roles/c3infodesk-deployment-role-test
- ls -la roles/c3infodesk-deployment-role-test/.gitlab-ci.yml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment