mirror of
https://github.com/davestephens/ansible-nas
synced 2025-01-13 12:08:53 +00:00
49 lines
1.3 KiB
YAML
49 lines
1.3 KiB
YAML
---
|
|
- name: Create Telegraf Directory
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
with_items:
|
|
- "{{ stats_telegraf_config_directory }}"
|
|
|
|
- name: Template telegraf.conf
|
|
template:
|
|
src: telegraf.conf.j2
|
|
dest: "{{ stats_telegraf_config_directory }}/telegraf.conf"
|
|
register: telegraf_config
|
|
|
|
- name: Get Docker daemon uid
|
|
command: stat -c '%g' /var/run/docker.sock
|
|
register: docker_uid
|
|
changed_when: false
|
|
|
|
- name: Telegraf Docker Container
|
|
docker_container:
|
|
name: stats-telegraf
|
|
image: telegraf
|
|
pull: true
|
|
privileged: true
|
|
ipc_mode: host
|
|
ports:
|
|
- "{{ stats_telegraf_influxdb_port }}:8086"
|
|
- "{{ stats_telegraf_port }}:9273"
|
|
user: "telegraf:{{ docker_uid.stdout }}"
|
|
volumes:
|
|
- "{{ stats_telegraf_config_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
|
|
restart: "{{ telegraf_config is changed }}"
|