57 lines
1.8 KiB
YAML
57 lines
1.8 KiB
YAML
|
|
# Synthetic monitoring playbook — provisions the blackbox-exporter
|
||
|
|
# Incus container and lays down the role.
|
||
|
|
#
|
||
|
|
# v1.0.9 W5 Day 24.
|
||
|
|
#
|
||
|
|
# IMPORTANT : the blackbox exporter SHOULD run on a host that is
|
||
|
|
# externally-routed (separate from the prod cluster) so a probe
|
||
|
|
# failure reflects what an external user sees. v1.0 lab keeps it on
|
||
|
|
# the same Incus host for simplicity ; phase-2 moves it off-box.
|
||
|
|
#
|
||
|
|
# Run with:
|
||
|
|
# ansible-galaxy collection install community.general
|
||
|
|
# ansible-playbook -i inventory/lab.yml playbooks/blackbox_exporter.yml
|
||
|
|
---
|
||
|
|
- name: Provision Incus container for blackbox exporter
|
||
|
|
hosts: incus_hosts
|
||
|
|
become: true
|
||
|
|
gather_facts: true
|
||
|
|
tasks:
|
||
|
|
- name: Launch blackbox-exporter container
|
||
|
|
ansible.builtin.shell:
|
||
|
|
cmd: |
|
||
|
|
set -e
|
||
|
|
if ! incus info blackbox-exporter >/dev/null 2>&1; then
|
||
|
|
incus launch images:ubuntu/22.04 blackbox-exporter
|
||
|
|
for _ in $(seq 1 30); do
|
||
|
|
if incus exec blackbox-exporter -- cloud-init status 2>/dev/null | grep -q "status: done"; then
|
||
|
|
break
|
||
|
|
fi
|
||
|
|
sleep 1
|
||
|
|
done
|
||
|
|
incus exec blackbox-exporter -- apt-get update
|
||
|
|
incus exec blackbox-exporter -- apt-get install -y python3 python3-apt
|
||
|
|
fi
|
||
|
|
args:
|
||
|
|
executable: /bin/bash
|
||
|
|
register: provision_result
|
||
|
|
changed_when: "'incus launch' in provision_result.stdout"
|
||
|
|
tags: [blackbox, provision]
|
||
|
|
|
||
|
|
- name: Refresh inventory
|
||
|
|
ansible.builtin.meta: refresh_inventory
|
||
|
|
|
||
|
|
- name: Apply common baseline
|
||
|
|
hosts: blackbox_exporter
|
||
|
|
become: true
|
||
|
|
gather_facts: true
|
||
|
|
roles:
|
||
|
|
- common
|
||
|
|
|
||
|
|
- name: Install + configure blackbox exporter
|
||
|
|
hosts: blackbox_exporter
|
||
|
|
become: true
|
||
|
|
gather_facts: true
|
||
|
|
roles:
|
||
|
|
- blackbox_exporter
|