From 0d3eaa6ac2dc448505b18c6aecd4a72e28ffde83 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 26 May 2023 16:29:23 +0930 Subject: [PATCH] feat(automation): job to run ansible playbooks !29 nofusscomputing/projects/ansible/execution_environment!8 nofusscomputing/projects/ansible-roles!25 nofusscomputing/projects/ansible/git_configuration#5 --- automation/.gitlab-ci-ansible.yaml | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 automation/.gitlab-ci-ansible.yaml diff --git a/automation/.gitlab-ci-ansible.yaml b/automation/.gitlab-ci-ansible.yaml new file mode 100644 index 0000000..b7d2350 --- /dev/null +++ b/automation/.gitlab-ci-ansible.yaml @@ -0,0 +1,60 @@ +--- +# This yaml is intended to automagically create automation jobs if included + +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: '' + # uncomment below when there is a playbook done + #ANSIBLE_PLAYBOOK_DIR: '/etc/ansible/playbooks' only use for role in the ansible-ee container + 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" + # remove galaxy and pip commands when the ansible-ee image is fixed + - ansible-galaxy collection install community.general + - pip install python_gitlab==3.14.0 + - ansible-playbook $ansible_inventory $ansible_playbook $ansible_tags -vvv --extra-vars repo_root=$CI_PROJECT_DIR + rules: + # test rules with default never and to specify only when + # - if: '$CI_COMMIT_TAG' + # when: never + # - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + # when: never + - 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 + + # this if for testing only + # - if: '$CI_PIPELINE_SOURCE == "push"' + # when: always + # exists: + # - ".nfc_automation.yaml" + - when: never + + + +Update Git Submodules: + extends: .ansible_playbook + variables: + ansible_playbook: '.nfc_automation.yaml' + ansible_tags: 'submodule' + PIPELINE_RUN_TRIGGER: 'false' + PIPELINE_RUN_SCHEDULE: 'false' + \ No newline at end of file