From b7e535a5af57eac7ee4e6bf84c47c2e81cb9dbef Mon Sep 17 00:00:00 2001 From: Alexandre Pires Date: Thu, 12 Dec 2024 18:55:04 +0100 Subject: [PATCH] Added new workflow --- .github/workflows/ansible-apply-host.yml | 38 ++++++++++++++++++++ .github/workflows/ansible-apply-playbook.yml | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ansible-apply-host.yml diff --git a/.github/workflows/ansible-apply-host.yml b/.github/workflows/ansible-apply-host.yml new file mode 100644 index 0000000..15c0e44 --- /dev/null +++ b/.github/workflows/ansible-apply-host.yml @@ -0,0 +1,38 @@ +name: Ansible Apply because of host_vars change +on: + push: + branches: + - main + paths: + - ansible/host_vars/*.yml +jobs: + ansible-apply: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup environment + id: setup_env + uses: ./.github/actions/setup-env + + - name: Setup Ansible environment + uses: ./.github/actions/setup-ansible-env + with: + vault-master-password: ${{ secrets.VAULT_MASTER_PASSWORD }} + ansible-user: ${{ secrets.ANSIBLE_USER }} + trusted-hosts: ${{ secrets.TRUSTED_HOSTS }} + + - name: Apply the playbook that triggered the workflow + env: + VAULT_MASTER_PASSWORD: ${{ secrets.VAULT_MASTER_PASSWORD }} + ANSIBLE_USER: ${{ secrets.ANSIBLE_USER }} + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + CHANGED_FILES: ${{ steps.setup_env.outputs.CHANGED_FILES }} + run: | + cd ansible + sectool exec ansible-playbook -u $ANSIBLE_USER playbook_login.yml + sectool exec ansible-playbook -u $ANSIBLE_USER playbook_cis.yml --skip-tags roles::cis::suid diff --git a/.github/workflows/ansible-apply-playbook.yml b/.github/workflows/ansible-apply-playbook.yml index 06c623f..118e2a2 100644 --- a/.github/workflows/ansible-apply-playbook.yml +++ b/.github/workflows/ansible-apply-playbook.yml @@ -1,4 +1,4 @@ -name: Ansible Validate Playbook on Pull Request +name: Ansible Apply Playbook that Triggered the Workflow on: push: branches: