Skip to content

Ansible --04- Uptime #11

Ansible --04- Uptime

Ansible --04- Uptime #11

name: Ansible -- Uptime
on:
workflow_dispatch:
inputs:
hosts:
description: 'The value for the variable_host argument'
required: true
default: 'none'
verbosity:
description: 'The verbosity level for logs'
required: true
type: choice
default: '-v'
options:
- '-v'
- '-vv'
- '-vvv'
jobs:
run_playbook:
name: Run Ansible Playbook
runs-on: ubuntu-latest
env:
WORKING_DIR: './ansible'
LINODE_API_TOKEN: ${{ secrets.LINODE_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- name: Setup Ansible and Dependencies
working-directory: ${{ env.WORKING_DIR }}
run: |
make install
ansible --version
- name: List Ansible Inventory
working-directory: ${{ env.WORKING_DIR }}
run: |
ansible-inventory --graph -v
- 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
# The following step is only needed if you are using Tailscale,
# we are not using it just yet.
# - name: Connect with Tailscale
# uses: tailscale/github-action@v2
# with:
# oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
# oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
# tags: tag:ci
- name: Ansible Playbook -- Uptime
working-directory: ${{ env.WORKING_DIR }}
run: |
ansible-playbook play-any--uptime.yml --private-key=~/.ssh/id_for_ansible.pem -e "variable_host=${{ github.event.inputs.hosts }}" ${{ github.event.inputs.verbosity }}