initial commit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
75891c3271
129 changed files with 8046 additions and 0 deletions
127
roles/monitoring/tasks/main.yml
Normal file
127
roles/monitoring/tasks/main.yml
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
---
|
||||
- name: Create monitoring directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
loop:
|
||||
- "{{ monitoring_data_path }}"
|
||||
- "{{ monitoring_data_path }}/prometheus"
|
||||
- "{{ monitoring_data_path }}/alloy"
|
||||
- "{{ monitoring_data_path }}/grafana"
|
||||
- "{{ monitoring_data_path }}/grafana/provisioning"
|
||||
- "{{ monitoring_data_path }}/grafana/provisioning/datasources"
|
||||
- "{{ monitoring_data_path }}/grafana/provisioning/dashboards"
|
||||
- "{{ monitoring_data_path }}/loki"
|
||||
|
||||
- name: Create textfile collector directory for node_exporter metrics
|
||||
file:
|
||||
path: /var/lib/node_exporter/textfile_collector
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Create container data directories with proper ownership
|
||||
ansible.builtin.shell: |
|
||||
mkdir -p "{{ item.path }}"
|
||||
chmod 755 "{{ item.path }}"
|
||||
chown {{ item.uid }}:{{ item.gid }} "{{ item.path }}"
|
||||
args:
|
||||
creates: "{{ item.path }}"
|
||||
loop:
|
||||
- { path: "{{ monitoring_data_path }}/prometheus/data", uid: 65534, gid: 65534 }
|
||||
- { path: "{{ monitoring_data_path }}/grafana/data", uid: 472, gid: 472 }
|
||||
- { path: "{{ monitoring_data_path }}/loki/data", uid: 10001, gid: 10001 }
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
|
||||
- name: Create Prometheus configuration
|
||||
template:
|
||||
src: prometheus.yml.j2
|
||||
dest: "{{ monitoring_data_path }}/prometheus/prometheus.yml"
|
||||
mode: '0644'
|
||||
notify: restart prometheus
|
||||
|
||||
- name: Create Alloy configuration
|
||||
template:
|
||||
src: config.alloy.j2
|
||||
dest: "{{ monitoring_data_path }}/alloy/config.alloy"
|
||||
mode: '0644'
|
||||
force: true
|
||||
notify: restart alloy
|
||||
|
||||
- name: Create Loki configuration
|
||||
template:
|
||||
src: loki-config.yaml.j2
|
||||
dest: "{{ monitoring_data_path }}/loki/loki-config.yaml"
|
||||
mode: '0644'
|
||||
force: true
|
||||
notify: restart loki
|
||||
|
||||
- name: Create Grafana datasource configuration
|
||||
template:
|
||||
src: datasources.yml.j2
|
||||
dest: "{{ monitoring_data_path }}/grafana/provisioning/datasources/datasources.yml"
|
||||
mode: '0644'
|
||||
|
||||
- name: Create Grafana dashboard provisioning config
|
||||
template:
|
||||
src: dashboards.yml.j2
|
||||
dest: "{{ monitoring_data_path }}/grafana/provisioning/dashboards/dashboards.yml"
|
||||
mode: '0644'
|
||||
|
||||
- name: Copy Node Exporter dashboard
|
||||
copy:
|
||||
src: node-exporter-dashboard.json
|
||||
dest: "{{ monitoring_data_path }}/grafana/provisioning/dashboards/node-exporter.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Copy System Metrics dashboard
|
||||
copy:
|
||||
src: system-metrics-dashboard.json
|
||||
dest: "{{ monitoring_data_path }}/grafana/provisioning/dashboards/system-metrics.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Copy Caddy dashboard
|
||||
copy:
|
||||
src: caddy-dashboard.json
|
||||
dest: "{{ monitoring_data_path }}/grafana/provisioning/dashboards/caddy.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Copy Mailserver dashboard
|
||||
copy:
|
||||
src: mailserver-dashboard.json
|
||||
dest: "{{ monitoring_data_path }}/grafana/provisioning/dashboards/mailserver.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Copy Forgejo dashboard
|
||||
copy:
|
||||
src: forgejo-dashboard.json
|
||||
dest: "{{ monitoring_data_path }}/grafana/provisioning/dashboards/forgejo.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Copy Service Overview dashboard
|
||||
copy:
|
||||
src: service-overview-dashboard.json
|
||||
dest: "{{ monitoring_data_path }}/grafana/provisioning/dashboards/service-overview.json"
|
||||
mode: '0644'
|
||||
|
||||
- name: Create compose file
|
||||
template:
|
||||
src: compose.yml.j2
|
||||
dest: "{{ monitoring_data_path }}/compose.yml"
|
||||
mode: '0644'
|
||||
register: compose_file
|
||||
notify: reload monitoring stack
|
||||
|
||||
- name: Deploy monitoring stack
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ monitoring_data_path }}"
|
||||
state: present
|
||||
build: never
|
||||
register: compose_output
|
||||
|
||||
- name: Show deployment status
|
||||
debug:
|
||||
msg: "Monitoring stack deployed. Grafana available at {{ grafana_root_url }}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue