prometheus/tasks/exporter/_docker.yml

47 lines
1.3 KiB
YAML
Raw Normal View History

2023-01-27 16:51:27 +01:00
---
- name: '{{ exporter }} exporter | check if docker is installed'
shell:
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:
path: "{{ docker_compose_directory }}"
state: directory
mode: '0755'
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | copy docker-compose file'
template:
src: compose/{{ exporter }}.yml.j2
dest: "/opt/docker-compose/{{ exporter }}/docker-compose.yml"
2023-01-27 16:51:27 +01:00
owner: root
group: root
mode: 0644
notify: "{{ exporter }}-restart"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | systemd | install unit file'
template:
src: systemd/docker-compose.service.j2
dest: "/etc/systemd/system/docker-compose@{{ exporter }}.service"
2023-01-27 16:51:27 +01:00
owner: root
group: root
mode: 0600
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | systemd | enable service'
systemd:
daemon_reload: yes
name: "docker-compose@{{ exporter }}"
2023-01-27 16:51:27 +01:00
enabled: true
ignore_errors: '{{ ansible_check_mode }}'
tags: [ 'prometheus_{{ exporter }}' ]