mirror of
https://github.com/davestephens/ansible-nas
synced 2024-12-26 11:33:08 +00:00
117 lines
3.5 KiB
YAML
117 lines
3.5 KiB
YAML
---
|
|
- name: Create InfluxDB and Telegraf Directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
with_items:
|
|
- "{{ influxdb_data_directory }}"
|
|
- "{{ telegraf_data_directory }}"
|
|
|
|
- name: Create Grafana Directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "472"
|
|
recurse: yes
|
|
with_items:
|
|
- "{{ grafana_data_directory }}"
|
|
- "{{ grafana_data_directory }}/data"
|
|
- "{{ grafana_data_directory }}/data/dashboards/ansible-nas"
|
|
- "{{ grafana_data_directory }}/config/"
|
|
- "{{ grafana_data_directory }}/config/provisioning"
|
|
- "{{ grafana_data_directory }}/config/provisioning/datasources"
|
|
- "{{ grafana_data_directory }}/config/provisioning/dashboards"
|
|
|
|
- name: InfluxDB
|
|
docker_container:
|
|
name: influxdb
|
|
image: influxdb
|
|
pull: true
|
|
volumes:
|
|
- "{{ influxdb_data_directory }}:/var/lib/influxdb:rw"
|
|
ports:
|
|
- "{{ grafana_influxdb_port }}:8086"
|
|
restart_policy: unless-stopped
|
|
env:
|
|
INFLUXDB_LOGGING_LEVEL: "error"
|
|
memory: 1g
|
|
|
|
- name: hddtemp
|
|
docker_container:
|
|
name: hddtemp
|
|
image: drewster727/hddtemp-docker
|
|
pull: true
|
|
privileged: true
|
|
restart_policy: unless-stopped
|
|
env:
|
|
HDDTEMP_ARGS: "-q -d -F /dev/sd*"
|
|
TZ: "{{ ansible_nas_timezone }}"
|
|
memory: 128m
|
|
|
|
- name: Template telegraf.conf
|
|
template:
|
|
src: telegraf/telegraf.conf
|
|
dest: "{{ telegraf_data_directory }}/telegraf.conf"
|
|
|
|
- name: Telegraf
|
|
docker_container:
|
|
name: telegraf
|
|
image: telegraf
|
|
pull: true
|
|
links:
|
|
- hddtemp:hddtemp
|
|
privileged: true
|
|
ipc_mode: host
|
|
volumes:
|
|
- "{{ telegraf_data_directory }}/telegraf.conf:/etc/telegraf/telegraf.conf:ro"
|
|
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
|
- "/:/hostfs:ro"
|
|
- "/etc:/hostfs/etc:ro"
|
|
- "/proc:/hostfs/proc:ro"
|
|
- "/sys:/hostfs/sys:ro"
|
|
- "/var:/hostfs/var:ro"
|
|
- "/run:/hostfs/run:ro"
|
|
env:
|
|
HOST_ETC: "/hostfs/etc"
|
|
HOST_PROC: "/hostfs/proc"
|
|
HOST_SYS: "/hostfs/sys"
|
|
HOST_VAR: "/hostfs/var"
|
|
HOST_RUN: "/hostfs/run"
|
|
HOST_MOUNT_PREFIX: "/hostfs"
|
|
restart_policy: unless-stopped
|
|
memory: 1g
|
|
|
|
- name: Template Grafana data source
|
|
template:
|
|
src: grafana/provisioning/datasources/ansible-nas.yml
|
|
dest: "{{ grafana_data_directory }}/config/provisioning/datasources/ansible-nas.yml"
|
|
|
|
- name: Copy Ansible-NAS Dashboard Provisioner
|
|
copy:
|
|
src: grafana/provisioning/dashboards/ansible-nas.yml
|
|
dest: "{{ grafana_data_directory }}/config/provisioning/dashboards/ansible-nas.yml"
|
|
|
|
- name: Copy Ansible-NAS Dashboard
|
|
copy:
|
|
src: grafana/dashboards/ansible-nas/ansible-nas-overview.json
|
|
dest: "{{ grafana_data_directory }}/data/dashboards/ansible-nas/ansible-nas-overview.json"
|
|
|
|
- name: Grafana
|
|
docker_container:
|
|
name: grafana
|
|
image: grafana/grafana
|
|
pull: true
|
|
volumes:
|
|
- "{{ grafana_data_directory }}/data:/var/lib/grafana:rw"
|
|
- "{{ grafana_data_directory }}/config/provisioning:/etc/grafana/provisioning:ro"
|
|
ports:
|
|
- "{{ grafana_port }}:3000"
|
|
restart_policy: unless-stopped
|
|
memory: 1g
|
|
labels:
|
|
traefik.enable: "{{ grafana_available_externally }}"
|
|
traefik.http.routers.grafana.rule: "Host(`grafana.{{ ansible_nas_domain }}`) "
|
|
traefik.http.routers.grafana.tls.certresolver: "letsencrypt"
|
|
traefik.http.routers.grafana.tls.domains[0].main: "{{ ansible_nas_domain }}"
|
|
traefik.http.routers.grafana.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
|
|
traefik.http.grafana.netdata.loadbalancer.server.port: "3000"
|