1
0
Fork 0
mirror of https://github.com/mdlayher/homelab.git synced 2024-12-14 11:47:32 +00:00

apcupsd_exporter: initial commit

This commit is contained in:
Matt Layher 2016-09-07 17:23:54 -04:00
parent 3e682d77d8
commit 871fd8bd7c
No known key found for this signature in database
GPG key ID: 77BFE531397EDE94
4 changed files with 92 additions and 0 deletions

View file

@ -0,0 +1,72 @@
---
- name: download and checksum apcupsd_exporter {{ apcupsd_exporter_version }} binary
tags:
- apcupsd_exporter
get_url:
url: "{{ apcupsd_exporter_url }}"
dest: "/tmp/apcupsd_exporter"
checksum: "sha256:{{ apcupsd_exporter_sha256 }}"
- name: create apcupsd_exporter user
tags:
- apcupsd_exporter
user:
name: apcupsd_exporter
shell: "/bin/false"
comment: "apcupsd_exporter service user"
- name: check if apcupsd_exporter service exists
tags:
- apcupsd_exporter
stat:
path: "/lib/systemd/system/apcupsd_exporter.service"
register: checked
- name: stop apcupsd_exporter service if it exists
tags:
- apcupsd_exporter
when: checked.stat.exists
service:
name: apcupsd_exporter
state: stopped
- name: copy apcupsd_exporter binary to /usr/local/bin
tags:
- apcupsd_exporter
command: "cp /tmp/apcupsd_exporter /usr/local/bin/"
- name: set permissions on apcupsd_exporter binary
tags:
- apcupsd_exporter
file:
path: "/usr/local/bin/apcupsd_exporter"
owner: apcupsd_exporter
group: apcupsd_exporter
mode: 0755
- name: create apcupsd_exporter systemd unit
tags:
- apcupsd_exporter
template:
src: apcupsd_exporter.service.j2
dest: "/lib/systemd/system/apcupsd_exporter.service"
- name: reload systemd configurations
tags:
- apcupsd_exporter
command: "systemctl daemon-reload"
- name: start apcupsd_exporter service
tags:
- apcupsd_exporter
service:
name: apcupsd_exporter
state: started
enabled: yes
- name: remove temporary files
tags:
- apcupsd_exporter
file:
path: "/tmp/apcupsd_exporter"
state: absent

View file

@ -0,0 +1,15 @@
# {{ ansible_managed }}
[Unit]
Description=Prometheus apcupsd exporter
Documentation=https://github.com/mdlayher/apcupsd_exporter
Wants=network-online.target
After=network-online.target
[Service]
User=apcupsd_exporter
Group=apcupsd_exporter
Type=simple
ExecStart=/usr/local/bin/apcupsd_exporter
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,4 @@
---
apcupsd_exporter_version: "0.1.0"
apcupsd_exporter_url: "https://github.com/mdlayher/apcupsd_exporter/releases/download/{{ apcupsd_exporter_version }}/apcupsd_exporter"
apcupsd_exporter_sha256: "217cfdfbd085657be5579b1cc691078fc5e2e6aaac4b3c72b45bbba05aba4b41"

View file

@ -6,6 +6,7 @@
- base
- sshkeys
- apcupsd
- apcupsd_exporter
- golang
- grafana
- nginx