Skip to content

Ansible --06- Cleanup Clients #14

Ansible --06- Cleanup Clients

Ansible --06- Cleanup Clients #14

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@b4ffde65f46336ab88eb53be808477a3936bae11
- 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 }}