From 391e424199195a2d71515d745bd09df317520ba9 Mon Sep 17 00:00:00 2001 From: Jacob Babor Date: Sun, 18 Aug 2024 01:07:24 -0500 Subject: [PATCH] Add some (admittedly crusty) support for podman for Prometheus monitoring --- playbooks/tags_nagios.yml | 98 ++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 31 deletions(-) diff --git a/playbooks/tags_nagios.yml b/playbooks/tags_nagios.yml index d6bdc3c..47acc05 100755 --- a/playbooks/tags_nagios.yml +++ b/playbooks/tags_nagios.yml @@ -2,7 +2,7 @@ # vim:ft=ansible: --- - hosts: tags_nagios - gather_facts: no + gather_facts: yes tasks: - name: assure nagios user ansible.builtin.user: name=nagios-checker state=absent remove=yes @@ -10,36 +10,72 @@ - name: assure nagios user sudo rule file ansible.builtin.file: path=/etc/sudoers.d/50-nagios-checker state=absent tags: [ nagios, sudo ] - - name: assure prometheus node exporter - # https://github.com/prometheus/node_exporter - ansible.builtin.docker_container: - name: prometheus-node-exporter - image: quay.io/prometheus/node-exporter:latest - restart_policy: unless-stopped - command: - - '--path.rootfs=/host' - - '--collector.interrupts' - - '--collector.processes' - network_mode: host - pid_mode: host - volumes: - - /:/host:ro,rslave - tags: [ prometheus ] - - name: assure prometheus cadvisor exporter - ansible.builtin.docker_container: - name: prometheus-cadvisor-exporter - image: gcr.io/cadvisor/cadvisor:latest - restart_policy: unless-stopped - ports: - - 9101:8080/tcp - volumes: - - /:/rootfs:ro - - /var/run:/var/run:ro - - /sys:/sys:ro - - /var/lib/docker:/var/lib/docker:ro - - /dev/disk:/dev/disk:ro - devices: - - /dev/kmsg + - name: assure prometheus containers for docker hosts + block: + - name: assure prometheus node exporter + # https://github.com/prometheus/node_exporter + ansible.builtin.docker_container: + name: prometheus-node-exporter + image: quay.io/prometheus/node-exporter:latest + restart_policy: unless-stopped + command: + - '--path.rootfs=/host' + - '--collector.interrupts' + - '--collector.processes' + network_mode: host + pid_mode: host + volumes: + - /:/host:ro,rslave + tags: [ prometheus ] + - name: assure prometheus cadvisor exporter + ansible.builtin.docker_container: + name: prometheus-cadvisor-exporter + image: gcr.io/cadvisor/cadvisor:latest + restart_policy: unless-stopped + ports: + - 9101:8080/tcp + volumes: + - /:/rootfs:ro + - /var/run:/var/run:ro + - /sys:/sys:ro + - /var/lib/docker:/var/lib/docker:ro + - /dev/disk:/dev/disk:ro + devices: + - /dev/kmsg + when: ansible_pkg_mgr != "atomic_container" + - name: assure prometheus containers for coreos + block: + - name: assure prometheus node exporter + # https://github.com/prometheus/node_exporter + containers.podman.podman_container: + name: prometheus-node-exporter + image: quay.io/prometheus/node-exporter:latest + restart_policy: unless-stopped + command: + - '--path.rootfs=/host' + - '--collector.interrupts' + - '--collector.processes' + network_mode: host + pid_mode: host + volumes: + - /:/host:ro,rslave + tags: [ prometheus ] + - name: assure prometheus cadvisor exporter + containers.podman.podman_container: + name: prometheus-cadvisor-exporter + image: gcr.io/cadvisor/cadvisor:latest + restart_policy: unless-stopped + privileged: yes + ports: + - 9101:8080/tcp + volumes: + - /:/rootfs:ro + - /var/run:/var/run:ro + - /sys:/sys:ro + - /dev/disk:/dev/disk:ro + device: + - /dev/kmsg + when: ansible_pkg_mgr == "atomic_container" - hosts: all gather_facts: no tasks: