1
0
Fork 0

deploy systemd file

This commit is contained in:
L3D 2022-11-21 17:57:49 +01:00
parent 9c85eef92a
commit e5d1924864
Signed by: l3d
GPG key ID: CD08445BFF4313D1
6 changed files with 36 additions and 4 deletions

View file

@ -2,7 +2,7 @@
- name: Create ping exporter config - name: Create ping exporter config
become: true become: true
ansible.builtin.template: ansible.builtin.template:
src: 'templates/ping_exporter_config.yml' src: 'templates/ping_exporter_config.yml.j2'
dest: "{{ ping_exporter__user_home }}/ping_exporter_config.yml" dest: "{{ ping_exporter__user_home }}/ping_exporter_config.yml"
mode: 0640 mode: 0640
owner: "{{ ping_exporter__user }}" owner: "{{ ping_exporter__user }}"

View file

@ -14,3 +14,6 @@
- name: Configurel ping exporter - name: Configurel ping exporter
ansible.builtin.include_tasks: config.yml ansible.builtin.include_tasks: config.yml
- name: Start systemd unit
ansible.builtin.include_tasks: systemd.yml

18
tasks/systemd.yml Normal file
View file

@ -0,0 +1,18 @@
---
- name: "Setup systemd service"
become: true
ansible.builtin.template:
src: 'templates/ping_exporter.service.j2'
dest: '/lib/systemd/system/ping_exporter.service'
owner: root
group: root
mode: 0644
notify:
- "Systemctl restart ping_exporter.service"
- name: "Reload systemd"
become: true
ansible.builtin.systemd:
daemon_reload: true
notify:
- "Systemctl restart ping_exporter.service"

View file

@ -0,0 +1,11 @@
# {{ ansible_managed }}
[Unit]
Description=Execute the ping_exporter server.
[Service]
WorkingDirectory={{ ping_exporter__user_home }}
ExecStart=/usr/bin/ping_exporter --config.path {{ ping_exporter__user_home }}/ping_exporter_config.yml
[Install]
WantedBy=multi-user.target

View file

@ -3,5 +3,5 @@ ping_exporter__repo: 'https://github.com/czerwonk/ping_exporter.git'
ping_exporter__repo_api: 'https://api.github.com/repos/czerwonk/ping_exporter/releases/latest' ping_exporter__repo_api: 'https://api.github.com/repos/czerwonk/ping_exporter/releases/latest'
# versionscheck # versionscheck
playbook_version_number: 02 # should be a integer playbook_version_number: 03 # should be a integer
playbook_version_path: 'do1jlr.prometheus_ping_exporter.version' playbook_version_path: 'do1jlr.prometheus_ping_exporter.version'