From 82231aa8ba482ee862ef825fcbdaa0d0a826c573 Mon Sep 17 00:00:00 2001 From: Egon Rijpkema Date: Wed, 2 Jan 2019 13:34:52 +0100 Subject: [PATCH] Added somewhat generic nod-exporter and cadvisor playbooks. --- cadvisor.yml | 5 +++++ node-exporter.yml | 5 +++++ roles/cadvisor/tasks/main.yml | 25 +++++++++++++++++++++++ roles/cadvisor/templates/cadvisor.service | 22 ++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 cadvisor.yml create mode 100644 node-exporter.yml create mode 100644 roles/cadvisor/tasks/main.yml create mode 100644 roles/cadvisor/templates/cadvisor.service diff --git a/cadvisor.yml b/cadvisor.yml new file mode 100644 index 0000000..93d679f --- /dev/null +++ b/cadvisor.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + become: True + roles: + - cadvisor diff --git a/node-exporter.yml b/node-exporter.yml new file mode 100644 index 0000000..93d679f --- /dev/null +++ b/node-exporter.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + become: True + roles: + - cadvisor diff --git a/roles/cadvisor/tasks/main.yml b/roles/cadvisor/tasks/main.yml new file mode 100644 index 0000000..a56b2e0 --- /dev/null +++ b/roles/cadvisor/tasks/main.yml @@ -0,0 +1,25 @@ +--- +- name: Install service files. + template: + src: templates/cadvisor.service + dest: /etc/systemd/system/cadvisor.service + mode: 644 + owner: root + group: root + tags: + - service-files + +- name: install service files + command: systemctl daemon-reload + +- name: enable service at boot + systemd: + name: cadvisor + enabled: yes + +- name: make sure servcies are started. + systemd: + name: cadvisor.service + state: restarted + tags: + - start-service diff --git a/roles/cadvisor/templates/cadvisor.service b/roles/cadvisor/templates/cadvisor.service new file mode 100644 index 0000000..730d324 --- /dev/null +++ b/roles/cadvisor/templates/cadvisor.service @@ -0,0 +1,22 @@ +[Unit] +Description=Prometheus container monitoring. +After=docker.service +Requires=docker.service + +[Service] +TimeoutStartSec=0 +Restart=always +ExecStartPre=-/usr/bin/docker kill %n +ExecStartPre=-/usr/bin/docker rm %n +ExecStart=/usr/bin/docker run --name %n \ + --volume=/:/rootfs:ro \ + --volume=/var/run:/var/run:rw \ + --volume=/sys:/sys:ro \ + --volume=/var/lib/docker/:/var/lib/docker:ro \ + --volume=/dev/disk/:/dev/disk:ro \ + --publish=8181:8080 \ + google/cadvisor:latest + + +[Install] +WantedBy=multi-user.target