ansible-playbooks

another attempt to have everything organized ...
git clone https://git.onna.be/ansible-playbooks.git
Log | Files | Refs | README | LICENSE

commit 0b5d8d93b56d134f7b0d649f34685029e1d56a96
Author: Paco Esteban <paco@e1e0.net>
Date:   Thu, 19 Dec 2019 19:32:19 +0100

initial commit

Diffstat:
Ahosts | 14++++++++++++++
Alocalutils.yml | 7+++++++
Aprometheus.yml | 10++++++++++
Aroles/upsc_exporter/defaults/main.yml | 5+++++
Aroles/upsc_exporter/files/upsc-exporter.service.j2 | 12++++++++++++
Aroles/upsc_exporter/handlers/main.yml | 9+++++++++
Aroles/upsc_exporter/tasks/main.yml | 26++++++++++++++++++++++++++
7 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/hosts b/hosts @@ -0,0 +1,14 @@ +[web] +r2.e1e0.net + +[mail] +mail01.e1e0.net + +[utils] +utils.e1e0.net + +[fw] +elrond.h.e1e0.net + +[localUtils] +pi2.h.e1e0.net diff --git a/localutils.yml b/localutils.yml @@ -0,0 +1,7 @@ +--- +- name: Install upsc node exporter + hosts: localUtils + remote_user: paco + become: yes + roles: + - upsc_exporter diff --git a/prometheus.yml b/prometheus.yml @@ -0,0 +1,10 @@ +--- +- name: prometheus server + hosts: elrond.h.e1e0.net + remote_user: paco + become: yes + become_method: doas + roles: + - prometheus + - grafana + - node_exporter diff --git a/roles/upsc_exporter/defaults/main.yml b/roles/upsc_exporter/defaults/main.yml @@ -0,0 +1,5 @@ +--- +exporter_port: 8081 +version: "v0.1.0" +checksum: "20c4abc0825be7340807d889ce1e3c6c415d5636e02ff4018a3c3b5d252af6fc" +ups: "ups@localhost" diff --git a/roles/upsc_exporter/files/upsc-exporter.service.j2 b/roles/upsc_exporter/files/upsc-exporter.service.j2 @@ -0,0 +1,12 @@ +[Unit] +Description=prometheus upsc exporter daemon +After=network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/upsc-exporter -p {{ exporter_port }} -ups {{ ups }} +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/roles/upsc_exporter/handlers/main.yml b/roles/upsc_exporter/handlers/main.yml @@ -0,0 +1,9 @@ +--- +- name: restart upsc-exporter + service: + name: upsc-exporter + state: restarted + +- name: reload systemd + systemd: + daemon_reload: yes diff --git a/roles/upsc_exporter/tasks/main.yml b/roles/upsc_exporter/tasks/main.yml @@ -0,0 +1,26 @@ +--- +- name: Download the exporter + get_url: + url: https://e1e0.net/repo/upsc-exporter-v0.1.0-linux-arm + dest: /usr/local/bin/upsc-exporter + mode: '0755' + owner: root + group: root + checksum: 'sha256:{{ checksum }}' + +- name: Install systemd service + template: + src: "files/upsc-exporter.service.j2" + dest: "/etc/systemd/system/upsc-exporter.service" + owner: root + group: root + mode: '0644' + notify: + - reload systemd + - restart upsc-exporter + +- name: enable and start service + systemd: + name: upsc-exporter + enabled: yes + state: started