feat: initial commit

This commit is contained in:
Simon Cornet 2025-10-23 16:06:21 +02:00
commit 4f744469c0
17 changed files with 324 additions and 0 deletions

14
tasks/cleanup.yaml Normal file
View file

@ -0,0 +1,14 @@
---
# cleanup
- name: "docker - prune all"
community.docker.docker_prune:
containers: true
images: true
networks: true
volumes: true
builder_cache: true
- name: "docker - force prune"
ansible.builtin.command: "docker system prune --all --force --volumes"
changed_when: false

48
tasks/grafana.yaml Normal file
View file

@ -0,0 +1,48 @@
---
# create directories
- name: "create grafana data directory"
ansible.builtin.file:
path: "/mnt/grafana"
state: "directory"
mode: "0775"
# run grafana
- name: "run grafana"
community.docker.docker_container:
# docker defaults
auto_remove: "no"
container_default_behavior: "no_defaults"
detach: "yes"
init: "no"
interactive: "no"
log_driver: "json-file"
log_options:
max-size: "5m"
max-file: "3"
memory: "0"
paused: "no"
privileged: "no"
pull: "always"
read_only: "no"
state: "started"
tty: "no"
# run grafana
name: "grafana"
image: "docker.io/grafana/grafana-oss:12.2.1"
image_name_mismatch: "recreate"
restart_policy: "unless-stopped"
network_mode: "host"
volumes:
- "/mnt/grafana:/var/lib/grafana"
env:
# grafana
GF_SECURITY_ADMIN_PASSWORD: "{{ grafana_admin_password }}"
# global
TZ: "{{ timezone }}"

13
tasks/main.yaml Normal file
View file

@ -0,0 +1,13 @@
---
# install prometheus
- name: "install prometheus"
ansible.builtin.import_tasks: "prometheus.yaml"
# install grafana
- name: "install grafana"
ansible.builtin.import_tasks: "grafana.yaml"
# cleanup docker
- name: "cleanup docker"
ansible.builtin.import_tasks: "cleanup.yaml"

66
tasks/prometheus.yaml Normal file
View file

@ -0,0 +1,66 @@
---
# create directories
- name: "create prometheus directory"
ansible.builtin.file:
path: "/mnt/prometheus"
state: "directory"
mode: "0775"
- name: "create prometheus data directory"
ansible.builtin.file:
path: "/mnt/prometheus/data"
state: "directory"
mode: "0775"
# create prometheus config
- name: "create prometheus config"
ansible.builtin.copy:
dest: "/mnt/prometheus/prometheus.yml"
mode: "0644"
content: |
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'unbound'
static_configs:
- targets: ['dns01.siempie.internal:9167']
- targets: ['dns02.siempie.internal:9167']
notify: "restart prometheus"
# run prometheus
- name: "run prometheus"
community.docker.docker_container:
# docker defaults
auto_remove: "no"
container_default_behavior: "no_defaults"
detach: "yes"
init: "no"
interactive: "no"
log_driver: "json-file"
log_options:
max-size: "5m"
max-file: "3"
memory: "0"
paused: "no"
privileged: "no"
pull: "always"
read_only: "no"
state: "started"
tty: "no"
# run prometheus
name: "prometheus"
image: "docker.io/prom/prometheus:3.7.2"
image_name_mismatch: "recreate"
restart_policy: "unless-stopped"
network_mode: "host"
volumes:
- "/mnt/prometheus/data:/prometheus"
- "/mnt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro"
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"