Ansible Playbooks #54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Ansible Playbooks | |
| on: | |
| schedule: | |
| - cron: "0 5 * * 2" | |
| workflow_dispatch: | |
| inputs: | |
| playbook: | |
| description: "Choose the Ansible playbook to run" | |
| required: true | |
| type: choice | |
| options: | |
| - docker-count.yml | |
| - docker-login.yml | |
| - git-pull-reset.yml | |
| - maint-reboot-required.yml | |
| - ntp.yml | |
| - zsh.yml | |
| - weekly/docker-prune.yml | |
| - weekly/apt.yml | |
| jobs: | |
| run-playbook: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| - name: Set up SSH agent | |
| run: | | |
| eval $(ssh-agent -s) | |
| ssh-add ~/.ssh/id_rsa | |
| - name: Run Playbooks | |
| env: | |
| BWS_ACCESS_TOKEN: ${{ secrets.BWS_ACCESS_TOKEN }} | |
| ANSIBLE_CONFIG: ansible/ansible.cfg | |
| run: | | |
| if [ -z "${{ github.event.inputs.playbook }}" ]; then | |
| echo "Running all playbooks in ansible/playbooks/weekly..." | |
| for playbook in ansible/playbooks/weekly/*.yml; do | |
| echo "Running $playbook..." | |
| ansible-playbook \ | |
| -i ansible/inventories/netbox/netbox.inventory.yml \ | |
| -i ansible/inventories/oracle/inventory.oci.yml \ | |
| -i ansible/inventories/proxmox/inventory.proxmox.yml \ | |
| "$playbook" \ | |
| --extra-vars "bw_access_token=${{ secrets.BWS_ACCESS_TOKEN }}" \ | |
| || echo "Playbook $playbook failed, continuing..." | |
| done | |
| else | |
| echo "Running selected playbook: ${{ github.event.inputs.playbook }}" | |
| ansible-playbook \ | |
| -i ansible/inventories/netbox/netbox.inventory.yml \ | |
| -i ansible/inventories/oracle/inventory.oci.yml \ | |
| -i ansible/inventories/proxmox/inventory.proxmox.yml \ | |
| "ansible/playbooks/${{ github.event.inputs.playbook }}" \ | |
| --extra-vars "bw_access_token=${{ secrets.BWS_ACCESS_TOKEN }}" | |
| fi |