feat(ansible): idempotent role-based host config for both production VMs
common/firewall/docker-tls/platform/lab-host/monitoring-agent/backup roles, orchestrated by site.yml with the ordering that matters (firewall/TLS land before the services that depend on them). Ansible Vault for secrets, no new tool introduced for this project's modest secret surface. Explicit dev/staging/production environment separation, no secrets committed (.gitignore covers vault plaintext, TLS keys, Terraform state, *.env). Validated: ansible-playbook --syntax-check clean.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
---
|
||||
# Deploys infra/monitoring/ configs to whichever host needs them. Named monitoring-agent for
|
||||
# historical reasons in this repo's role list, but it deploys both the "agent" pieces
|
||||
# (node-exporter/cadvisor/promtail configs, already referenced directly by the platform/
|
||||
# lab-host compose files) and the central stack's config (Prometheus/Alertmanager/Loki/Grafana
|
||||
# on rn-platform-01 only).
|
||||
|
||||
- name: Create /opt/rootnode/monitoring (rn-platform-01)
|
||||
ansible.builtin.file:
|
||||
path: /opt/rootnode/monitoring/rules
|
||||
state: directory
|
||||
mode: "0755"
|
||||
when: inventory_hostname in groups['platform']
|
||||
|
||||
- name: Deploy Prometheus config
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/../../../monitoring/prometheus/prometheus.yml.j2"
|
||||
dest: /opt/rootnode/monitoring/prometheus.yml
|
||||
mode: "0644"
|
||||
when: inventory_hostname in groups['platform']
|
||||
notify: reload prometheus
|
||||
|
||||
- name: Deploy alert rules
|
||||
ansible.builtin.copy:
|
||||
src: "{{ role_path }}/../../../monitoring/prometheus/rules/rootnode.yml"
|
||||
dest: /opt/rootnode/monitoring/rules/rootnode.yml
|
||||
mode: "0644"
|
||||
when: inventory_hostname in groups['platform']
|
||||
notify: reload prometheus
|
||||
|
||||
- name: Deploy blackbox_exporter config
|
||||
ansible.builtin.copy:
|
||||
src: "{{ role_path }}/../../../monitoring/prometheus/blackbox.yml"
|
||||
dest: /opt/rootnode/monitoring/blackbox.yml
|
||||
mode: "0644"
|
||||
when: inventory_hostname in groups['platform']
|
||||
|
||||
- name: Deploy Alertmanager config
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/../../../monitoring/alertmanager/alertmanager.yml.j2"
|
||||
dest: /opt/rootnode/monitoring/alertmanager.yml
|
||||
mode: "0644"
|
||||
when: inventory_hostname in groups['platform']
|
||||
notify: reload alertmanager
|
||||
|
||||
- name: Deploy Loki config
|
||||
ansible.builtin.copy:
|
||||
src: "{{ role_path }}/../../../monitoring/loki/loki-config.yml"
|
||||
dest: /opt/rootnode/monitoring/loki-config.yml
|
||||
mode: "0644"
|
||||
when: inventory_hostname in groups['platform']
|
||||
|
||||
- name: Deploy Grafana provisioning + dashboards
|
||||
ansible.builtin.copy:
|
||||
src: "{{ role_path }}/../../../monitoring/grafana/{{ item }}/"
|
||||
dest: "/opt/rootnode/monitoring/grafana/{{ item }}/"
|
||||
mode: "0644"
|
||||
loop: [provisioning, dashboards]
|
||||
when: inventory_hostname in groups['platform']
|
||||
|
||||
- name: Deploy platform-side promtail config
|
||||
ansible.builtin.copy:
|
||||
src: "{{ role_path }}/../../../monitoring/promtail/promtail-config.platform.yml"
|
||||
dest: /opt/rootnode/monitoring/promtail-config.yml
|
||||
mode: "0644"
|
||||
when: inventory_hostname in groups['platform']
|
||||
notify: restart platform promtail
|
||||
|
||||
- name: Deploy lab-host promtail config
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/../../../monitoring/promtail/promtail-config.lab-host.yml.j2"
|
||||
dest: /opt/rootnode/lab-host/promtail-config.yml
|
||||
mode: "0644"
|
||||
when: inventory_hostname in groups['lab_host']
|
||||
notify: restart lab-host promtail
|
||||
Reference in New Issue
Block a user