Merge branch 'restructure' into 'development'

feat(automation): job to run ansible playbooks

Closes #25

See merge request nofusscomputing/projects/gitlab-ci!29
This commit is contained in:
2023-05-27 05:57:13 +00:00
4 changed files with 103 additions and 1 deletions

View File

@ -1,9 +1,11 @@
variables:
JOB_ROOT_DIR: 'gitlab-ci'
GIT_SUBMODULE_STRATEGY: recursive
PIPELINE_RUN_TRIGGER: 'false'
PIPELINE_RUN_SCHEDULE: 'true'
stages:
- chores
- validation
- build
- prepare

View File

@ -0,0 +1,44 @@
---
# This yaml is intended to run ansible jobs using nfc's ansible-ee image
include:
- local: $JOB_ROOT_DIR/.gitlab-ci_common.yaml
.ansible_playbook:
image: nofusscomputing/ansible-ee:dev
stage: chores
variables:
ansible_inventory: ''
ansible_playbook: ''
ansible_tags: ''
script:
- if [ "0$ansible_inventory" != '0' ]; then ansible_inventory=-i $ansible_inventory; fi
- if [ "0$ansible_tags" != '0' ]; then ansible_tags=$(echo -n "--tags $ansible_tags"); fi
- echo "[DEBUG] ansible_inventory=$ansible_inventory"
- echo "[DEBUG] ansible_playbook=$ansible_playbook"
- echo "[DEBUG] ansible_tags=$ansible_tags"
- ansible-playbook $ansible_inventory $ANSIBLE_PLAYBOOK_DIR/$ansible_playbook $ansible_tags -vvv
rules:
- if: '$NFC_AUTO_JOBS == "false"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule" && $PIPELINE_RUN_SCHEDULE == "true"'
exists:
- ".nfc_automation.yaml"
when: always
- if: '$CI_PIPELINE_SOURCE == "pipeline" && $PIPELINE_RUN_TRIGGER == "true"'
exists:
- ".nfc_automation.yaml"
when: always
- if: "$CI_COMMIT_BRANCH == 'development'" # on push to dev run to chek for update
exists:
- ".nfc_automation.yaml"
when: always
# this if for testing only
# - if: '$CI_PIPELINE_SOURCE == "push"'
# when: always
# exists:
# - ".nfc_automation.yaml"
- when: never

View File

@ -21,6 +21,9 @@ about: https://gitlab.com/nofusscomputing/projects/gitlab-ci
The CI stages for these jobs are as follows, and in the order expected by the jobs:
- chores
> automated tasks
- validation
> validation of files, commits, Merge Request titles, code quality, license checks.

View File

@ -0,0 +1,53 @@
# This gitlab-ci file is used for the autocreation of ci jobs.
# by including this file, the jobs will be autocreated if they are detected as required.
variables:
NFC_AUTO_JOBS: 'true'
include:
- local: $JOB_ROOT_DIR/.gitlab-ci_common.yaml
# Chore
- local: $JOB_ROOT_DIR/automation/.gitlab-ci-ansible.yaml
# Validation
- local: $JOB_ROOT_DIR/lint/ansible.gitlab-ci.yaml
- local: $JOB_ROOT_DIR/conventional_commits/.gitlab-ci.yml
# sync
- local: $JOB_ROOT_DIR/git_push_mirror/.gitlab-ci.yml
# release
- local: $JOB_ROOT_DIR/gitlab_release/.gitlab-ci.yml
# templates
- local: $JOB_ROOT_DIR/template/docker-image.gitlab-ci.yaml
- local: $JOB_ROOT_DIR/template/website.gitlab-ci.yaml
#
# Chores
#
Update Git Submodules:
extends: .ansible_playbook
variables:
ansible_playbook: 'git_configuration.yaml'
ansible_tags: 'submodule'
PIPELINE_RUN_TRIGGER: 'false'
PIPELINE_RUN_SCHEDULE: 'false'
#
# Release
#
Gitlab Release:
extends:
- .gitlab_release
#
# Sync
#
Github (Push --mirror):
extends:
- .git_push_mirror