Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(housekeeping): create a uptime check action #601

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/ansible--uptime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Ansible -- Uptime
on:
workflow_dispatch:
inputs:
hosts:
description: 'The value for the variable hosts argument'
required: true
default: 'none'

verbosity:
description: 'The verbosity level for logs'
required: true
type: choice
default: ''
options:
- '-v'
- '-vv'
- '-vvv'

jobs:
run_playbook:
runs-on: ubuntu-latest
env:
WORKING_DIR: './ansible'
LINODE_API_TOKEN: ${{ secrets.LINODE_TOKEN }}

steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744

- name: Set up Python 3
uses: actions/setup-python@v3
with:
python-version: '3.11'

- name: Setup pip
run: |
python -m pip install --upgrade pip

- name: Install Ansible and other dependencies
working-directory: ${{ env.WORKING_DIR }}
run: |
make install

- name: Ansible Inventory
working-directory: ${{ env.WORKING_DIR }}
run: |
ansible-inventory --graph -v

- name: 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
working-directory: ${{ env.WORKING_DIR }}
run: |
ansible-playbook play-any--uptime.yml -e "variable_hosts=${{ github.event.inputs.hosts }}" ${{ github.event.inputs.verbosity }}
2 changes: 1 addition & 1 deletion ansible/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ help:
install:
pip install ansible ansible-lint
pip install -r requirements/python.txt
ansible-galaxy install -r requirements/roles.yml
# ansible-galaxy install -r requirements/roles.yml
ansible-galaxy collection install -r requirements/collections.yml

.PHONY: check-linode-env-token
Expand Down
7 changes: 3 additions & 4 deletions ansible/play-any--uptime.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
- name: Check uptime on virtual machines
hosts: '{{ variable_host | default("all") }}'
hosts: '{{ variable_host | default("none") }}'
gather_facts: true
become_user: root
serial: '{{ variable_serial | default(1) }}'
tasks:
- name: Print uptime
debug:
msg:
'Host machine {{ inventory_hostname }} has been up for {{
ansible_facts.uptime_seconds/86400 }} days'
msg: 'Host machine {{ inventory_hostname }} has been up for {{ ansible_facts.uptime_seconds/86400 }} days'