forked from bitlair/ansible
monitoring/mqtt_exporter: Install from debian package
This commit is contained in:
parent
bb5f845c1b
commit
ee6b8bee5c
9 changed files with 47 additions and 33 deletions
|
@ -36,3 +36,6 @@ mqtt_public_host: bitlair.nl
|
||||||
debian_repourl: "http://deb.debian.org/debian/"
|
debian_repourl: "http://deb.debian.org/debian/"
|
||||||
debian_securityurl: "http://security.debian.org/debian-security"
|
debian_securityurl: "http://security.debian.org/debian-security"
|
||||||
|
|
||||||
|
deb_forgejo_repos:
|
||||||
|
- host: git.polyfloyd.net
|
||||||
|
owner: polyfloyd
|
||||||
|
|
|
@ -4,5 +4,6 @@
|
||||||
roles:
|
roles:
|
||||||
- { role: "common", tags: [ "common" ] }
|
- { role: "common", tags: [ "common" ] }
|
||||||
- { role: "acme", tags: [ "acme" ] }
|
- { role: "acme", tags: [ "acme" ] }
|
||||||
|
- { role: "deb_forgejo", tags: [ "deb_forgejo" ] }
|
||||||
- { role: "nginx", tags: [ "nginx" ] }
|
- { role: "nginx", tags: [ "nginx" ] }
|
||||||
- { role: "monitoring", tags: [ "monitoring" ] }
|
- { role: "monitoring", tags: [ "monitoring" ] }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: update-grub
|
cmd: update-grub
|
||||||
|
|
||||||
- name: Apt update
|
- name: apt update
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
|
|
1
roles/deb_forgejo/defaults/main.yaml
Normal file
1
roles/deb_forgejo/defaults/main.yaml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
deb_private_host: git.polyfloyd.net
|
3
roles/deb_forgejo/handlers/default.yaml
Normal file
3
roles/deb_forgejo/handlers/default.yaml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
- ansible.builtin.import_tasks:
|
||||||
|
file: ../../common/handlers/main.yaml
|
26
roles/deb_forgejo/tasks/main.yaml
Normal file
26
roles/deb_forgejo/tasks/main.yaml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
- tags: deb_forgejo
|
||||||
|
block:
|
||||||
|
- name: Install dependencies
|
||||||
|
apt:
|
||||||
|
name: apt-transport-https
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install packaging key
|
||||||
|
get_url:
|
||||||
|
url: https://{{ item.host }}/api/packages/{{ item.owner }}/debian/repository.key
|
||||||
|
dest: /etc/apt/keyrings/{{ item.host }}-{{ item.owner }}.asc
|
||||||
|
mode: "0644"
|
||||||
|
with_items: "{{ deb_forgejo_repos }}"
|
||||||
|
notify: apt update
|
||||||
|
|
||||||
|
- name: Install sources.list
|
||||||
|
template:
|
||||||
|
src: sources.list
|
||||||
|
dest: /etc/apt/sources.list.d/deb-forgejo.list
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: apt update
|
||||||
|
|
||||||
|
- meta: flush_handlers
|
5
roles/deb_forgejo/templates/sources.list
Normal file
5
roles/deb_forgejo/templates/sources.list
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
{% for repo in deb_forgejo_repos %}
|
||||||
|
deb [signed-by=/etc/apt/keyrings/{{ repo.host }}-{{ repo.owner }}.asc] https://{{ repo.host }}/api/packages/{{ repo.owner }}/debian {{ repo.distro | default('stable') }} {{ repo.component | default('main') }}
|
||||||
|
{% endfor %}
|
|
@ -15,7 +15,7 @@
|
||||||
-o /usr/share/keyrings/nodesource.gpg
|
-o /usr/share/keyrings/nodesource.gpg
|
||||||
args:
|
args:
|
||||||
creates: /usr/share/keyrings/nodesource.gpg
|
creates: /usr/share/keyrings/nodesource.gpg
|
||||||
notify: Apt update
|
notify: apt update
|
||||||
|
|
||||||
- name: Install nodesource source list
|
- name: Install nodesource source list
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify: Apt update
|
notify: apt update
|
||||||
|
|
||||||
- name: Install nodejs apt preference
|
- name: Install nodejs apt preference
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify: Apt update
|
notify: apt update
|
||||||
|
|
||||||
- ansible.builtin.meta: flush_handlers
|
- ansible.builtin.meta: flush_handlers
|
||||||
|
|
||||||
|
|
|
@ -1,47 +1,22 @@
|
||||||
---
|
---
|
||||||
- name: Clone source
|
|
||||||
ansible.builtin.git:
|
|
||||||
repo: https://github.com/polyfloyd/mqtt-exporter.git
|
|
||||||
version: main
|
|
||||||
dest: /opt/mqtt_exporter
|
|
||||||
accept_hostkey: yes
|
|
||||||
notify: restart mqtt_exporter
|
|
||||||
|
|
||||||
- name: Install apt dependencies
|
- name: Install apt dependencies
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name: mqtt-exporter
|
||||||
- jq
|
|
||||||
- python3-paho-mqtt
|
|
||||||
- python3-prometheus-client
|
|
||||||
- python3-yaml
|
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Install service
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: mqtt_exporter.service
|
|
||||||
dest: /etc/systemd/system/mqtt_exporter.service
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
notify:
|
|
||||||
- Daemon reload
|
|
||||||
- restart mqtt_exporter
|
|
||||||
|
|
||||||
- name: Install config file
|
- name: Install config file
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: mqtt_exporter_config.yaml
|
src: mqtt_exporter_config.yaml
|
||||||
dest: /etc/mqtt_exporter.yaml
|
dest: /etc/mqtt-exporter.yaml
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
notify:
|
notify: restart mqtt_exporter
|
||||||
- Daemon reload
|
|
||||||
- restart mqtt_exporter
|
|
||||||
|
|
||||||
- ansible.builtin.meta: flush_handlers
|
- ansible.builtin.meta: flush_handlers
|
||||||
|
|
||||||
- name: Start service
|
- name: Start service
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: mqtt_exporter
|
name: mqtt-exporter
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue