From 3142ba75c64b15e8c5d0bcc3eebe6c190a2c0157 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 28 Jan 2020 21:50:29 +0000 Subject: [PATCH] Add netdata docker-compose file --- .../docker/files/netdata/docker-compose.yml | 21 ++++++++++++ ansible/roles/docker/tasks/main.yml | 3 ++ ansible/roles/docker/tasks/netdata.yml | 32 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 ansible/roles/docker/files/netdata/docker-compose.yml create mode 100644 ansible/roles/docker/tasks/netdata.yml diff --git a/ansible/roles/docker/files/netdata/docker-compose.yml b/ansible/roles/docker/files/netdata/docker-compose.yml new file mode 100644 index 0000000..1b18ae9 --- /dev/null +++ b/ansible/roles/docker/files/netdata/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3' +services: + netdata: + image: netdata/netdata:latest + container_name: netdata + cap_add: + - SYS_PTRACE + security_opt: + - apparmor:unconfined + volumes: + - /etc/passwd:/host/etc/passwd:ro + - /etc/group:/host/etc/group:ro + - /proc:/host/proc:ro + - /sys:/host/sys:ro + restart: unless-stopped + labels: + - "traefik.enable=true" + - "traefik.http.routers.netdata.rule=Host(`netdata.jakehoward.tech`)" + - "traefik.http.routers.netdata.tls=true" + - "traefik.http.routers.netdata.tls.certresolver=le" + - "traefik.http.routers.netdata.middlewares=internal-only@file" diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml index ebd465f..f1483a5 100644 --- a/ansible/roles/docker/tasks/main.yml +++ b/ansible/roles/docker/tasks/main.yml @@ -3,3 +3,6 @@ - name: Install Docker include: setup-docker.yml + +- name: Install netdata + include: netdata.yml diff --git a/ansible/roles/docker/tasks/netdata.yml b/ansible/roles/docker/tasks/netdata.yml new file mode 100644 index 0000000..c206d52 --- /dev/null +++ b/ansible/roles/docker/tasks/netdata.yml @@ -0,0 +1,32 @@ +- name: Create netdata directory + file: + path: '/opt/netdata' + state: directory + owner: "{{ docker_user.name }}" + mode: 0755 + become: true + become_user: root + +- name: Install netdata config + template: + src: files/netdata/docker-compose.yml + dest: "/opt/netdata/docker-compose.yml" + mode: 0644 + owner: "{{ docker_user.name }}" + backup: true + trim_blocks: false + register: compose_file + become: true + become_user: root + +- name: Cycle container + docker_compose: + project_src: /opt/netdata + pull: true + remove_orphans: true + remove_volumes: true + state: "{{ item }}" + when: compose_file.changed + loop: + - absent + - present