Ansible --06- Cleanup Clients #28
This file contains 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 --06- Cleanup Clients | |
on: | |
schedule: | |
- cron: '5 12 10,20 * *' # Run at 12:05 on the 10th and 20th of every month | |
workflow_dispatch: | |
inputs: | |
verbosity: | |
description: 'The verbosity level for logs' | |
type: choice | |
required: true | |
default: '-v' | |
options: | |
- '-v' | |
- '-vv' | |
- '-vvv' | |
serial: | |
description: 'The value for the variable_serial argument' | |
type: number | |
jobs: | |
run_playbook: | |
name: Run Play | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
host_groups: | |
- 'prd_oldeworld_clt' | |
- 'stg_oldeworld_clt' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc | |
- name: Setup Ansible and Dependencies | |
env: | |
LINODE_API_TOKEN: ${{ secrets.LINODE_TOKEN }} | |
working-directory: './ansible' | |
run: | | |
make install | |
ansible --version | |
- name: Set up SSH key | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_for_ansible.pem | |
chmod 600 ~/.ssh/id_for_ansible.pem | |
- name: Play -- Cleanup Clients | |
env: | |
LINODE_API_TOKEN: ${{ secrets.LINODE_TOKEN }} | |
working-directory: './ansible' | |
run: | | |
SERIAL_VALUE=${{ inputs.serial || 1 }} # Default value of 1 if inputs.serial is not set | |
ansible-playbook play-any--cleanup-clients.yml \ | |
--private-key=~/.ssh/id_for_ansible.pem \ | |
-e '{"variable_host": "${{ matrix.host_groups }}", "variable_serial": '$SERIAL_VALUE'}' \ | |
${{ inputs.verbosity }} |