2023-01-27 16:51:27 +01:00
|
|
|
---
|
|
|
|
- name: '{{ exporter }} exporter | check if docker is installed'
|
|
|
|
shell:
|
2023-02-07 10:14:31 +01:00
|
|
|
cmd: "{{ item }} --help"
|
2023-01-27 16:51:27 +01:00
|
|
|
register: result
|
|
|
|
check_mode: false
|
|
|
|
changed_when: false
|
|
|
|
failed_when: result.rc != 0 and result.rc != 127
|
|
|
|
with_items:
|
|
|
|
- docker
|
|
|
|
- docker-compose
|
|
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|
|
|
|
|
|
|
|
- name: '{{ exporter }} exporter | create docker-compose directory'
|
|
|
|
file:
|
2023-02-07 10:54:51 +01:00
|
|
|
path: "{{ docker_compose_directory }}/{{ exporter }}"
|
2023-01-27 16:51:27 +01:00
|
|
|
state: directory
|
|
|
|
mode: '0755'
|
|
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|
|
|
|
|
|
|
|
- name: '{{ exporter }} exporter | copy docker-compose file'
|
|
|
|
template:
|
|
|
|
src: compose/{{ exporter }}.yml.j2
|
2023-02-07 10:14:31 +01:00
|
|
|
dest: "/opt/docker-compose/{{ exporter }}/docker-compose.yml"
|
2023-01-27 16:51:27 +01:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2023-02-07 10:48:43 +01:00
|
|
|
notify:
|
2023-02-10 11:13:37 +01:00
|
|
|
- '{{ exporter }}-exporter-restart'
|
2023-01-27 16:51:27 +01:00
|
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|
|
|
|
|
|
|
|
- name: '{{ exporter }} exporter | systemd | install unit file'
|
|
|
|
template:
|
|
|
|
src: systemd/docker-compose.service.j2
|
2023-02-07 10:14:31 +01:00
|
|
|
dest: "/etc/systemd/system/docker-compose@{{ exporter }}.service"
|
2023-01-27 16:51:27 +01:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0600
|
2023-02-07 10:48:43 +01:00
|
|
|
notify:
|
2023-02-10 11:13:37 +01:00
|
|
|
- '{{ exporter }}-exporter-restart'
|
2023-01-27 16:51:27 +01:00
|
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|
|
|
|
|
|
|
|
- name: '{{ exporter }} exporter | systemd | enable service'
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
2023-02-07 10:14:31 +01:00
|
|
|
name: "docker-compose@{{ exporter }}"
|
2023-01-27 16:51:27 +01:00
|
|
|
enabled: true
|
|
|
|
ignore_errors: '{{ ansible_check_mode }}'
|
|
|
|
tags: [ 'prometheus_{{ exporter }}' ]
|