Raspberry-Pi-IaC/roles/monitoring/tasks/main.yml
2025-03-15 13:27:25 +01:00

101 lines
3.6 KiB
YAML

---
# See: https://github.com/google/cadvisor/issues/3469#issuecomment-2005749081
# Also seems to require a reboot...
- name: Append cgroup variables to RaspberryPi file
become: true
ansible.builtin.lineinfile:
path: /boot/firmware/cmdline.txt
backrefs: true
regexp: "^(.*rootwait)$" # Just the default value in the file at the end, hopefully this works on fresh installs as well...
line: '\1 cgroup_memory=1 cgroup_enable=memory'
- name: Install the container
become: true
community.docker.docker_container:
name: cadvisor
image: "gcr.io/cadvisor/cadvisor:{{ versions.monitoring.cAdvisor }}"
image_name_mismatch: recreate
ports:
- "127.0.0.1:8091:8080/tcp"
mounts:
- source: /
target: /rootfs
read_only: true
type: bind
- source: /var/run
target: /var/run
read_only: true
type: bind
- source: /sys
target: /sys
read_only: true
type: bind
- source: /var/lib/docker/
target: /var/lib/docker
read_only: true
type: bind
- source: /dev/disk/
target: /dev/disk
read_only: true
type: bind
privileged: true
devices:
- /dev/kmsg
restart_policy: always
- name: Include simple-reverse-proxy role
ansible.builtin.include_role:
name: simple-reverse-proxy
vars:
simple_reverse_proxy_internal_port: 8091
simple_reverse_proxy_internal_subdomain: cadvisor
- name: Include the Prometheus role
ansible.builtin.include_role:
name: prometheus.prometheus.prometheus
- name: Include simple-reverse-proxy role - Prometheus
ansible.builtin.include_role:
name: simple-reverse-proxy
vars:
simple_reverse_proxy_internal_port: 9090
simple_reverse_proxy_internal_subdomain: prometheus
- name: Include the Prometheus - node exporter role
ansible.builtin.include_role:
name: prometheus.prometheus.node_exporter
- name: Include the Prometheus - alertmanager role
ansible.builtin.include_role:
name: prometheus.prometheus.alertmanager
- name: Include simple-reverse-proxy role - Prometheus
ansible.builtin.include_role:
name: simple-reverse-proxy
vars:
simple_reverse_proxy_internal_port: 9093
simple_reverse_proxy_internal_subdomain: alertmanager
# region: Install Grafana
# With the current approach we store the internal database in a docker volume which is included in the backup. All data included
# consists of configuration of grafana: user information, dashboards, datasources, etc.
# Previously, restoring the backup failed with some log errors and the inability to log in after restore.
# An alternative approach could be to configure more in code using environment variables for the container (see:
# https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/#use-environment-variables-to-configure-grafana).
# This has certain advantages and disadvantages.
- name: Create a volume
become: true
community.docker.docker_volume:
name: grafana_data
- name: Install the container
become: true
community.docker.docker_container:
name: grafana-server
image: "docker.io/grafana/grafana:{{ versions.monitoring.grafana }}"
image_name_mismatch: recreate
ports:
- "127.0.0.1:3000:3000/tcp"
mounts:
- source: grafana_data
target: /var/lib/grafana
env:
GF_INSTALL_PLUGINS: "grafana-clock-panel 2.1.8"
restart_policy: always
- name: Include simple-reverse-proxy role
ansible.builtin.include_role:
name: simple-reverse-proxy
vars:
simple_reverse_proxy_internal_port: 3000
simple_reverse_proxy_internal_subdomain: grafana