You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.5 KiB
YAML
81 lines
2.5 KiB
YAML
---
|
|
- name: Mongodb exporter
|
|
block:
|
|
- name: Create the user under the mongodb exporter will run
|
|
ansible.builtin.user:
|
|
name: '{{ mongodb_prometheus_exporter_user }}'
|
|
home: '{{ mongodb_prometheus_exporter_home }}'
|
|
createhome: no
|
|
shell: /usr/sbin/nologin
|
|
system: yes
|
|
|
|
- name: Create the prometheus mongodb exporter base directory
|
|
ansible.builtin.file:
|
|
dest: '{{ item }}'
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
loop:
|
|
- '{{ mongodb_prometheus_exporter_home }}'
|
|
- '{{ mongodb_prometheus_exporter_dist_dir }}'
|
|
|
|
- name: Download the prometheus mongodb exporter
|
|
ansible.builtin.get_url:
|
|
url: '{{ mongodb_prometheus_exporter_download_url }}'
|
|
dest: /srv/
|
|
|
|
- name: Unarchive the prometheus distribution
|
|
ansible.builtin.unarchive:
|
|
src: '/srv/{{ mongodb_prometheus_exporter_file }}'
|
|
dest: '{{ mongodb_prometheus_exporter_dist_dir }}'
|
|
remote_src: yes
|
|
owner: root
|
|
group: root
|
|
args:
|
|
creates: '{{ mongodb_prometheus_exporter_dist_dir }}/{{ mongodb_prometheus_exporter_dir }}/mongodb_exporter'
|
|
notify: Restart mongodb exporter
|
|
|
|
- name: Install the prometheus node exporter upstart script
|
|
ansible.builtin.template:
|
|
src: mongodb_exporter.upstart.j2
|
|
dest: /etc/init/mongodb_exporter.conf
|
|
mode: 0644
|
|
owner: root
|
|
group: root
|
|
when: ansible_service_mgr != 'systemd'
|
|
notify: Restart mongodb exporter
|
|
|
|
- name: Install the prometheus mongodb exporter systemd unit
|
|
ansible.builtin.template:
|
|
src: mongodb_exporter.service.j2
|
|
dest: /etc/systemd/system/mongodb_exporter.service
|
|
mode: 0644
|
|
owner: root
|
|
group: root
|
|
when: ansible_service_mgr == 'systemd'
|
|
notify:
|
|
- Reload the systemd data
|
|
- Restart mongodb exporter
|
|
|
|
- ansible.builtin.meta: flush_handlers
|
|
|
|
- name: Ensure that prometheus mongodb_exporter is started and enabled
|
|
ansible.builtin.service:
|
|
name: mongodb_exporter
|
|
state: started
|
|
enabled: yes
|
|
|
|
when: mongodb_prometheus_exporter_enabled
|
|
tags: [ 'mongodb', 'prometheus', 'mongodb_prometheus' ]
|
|
|
|
- name: No mongodb exporter
|
|
block:
|
|
- name: Ensure that prometheus mongodb_exporter is stopped and disabled
|
|
ansible.builtin.service:
|
|
name: mongodb_exporter
|
|
state: stopped
|
|
enabled: no
|
|
|
|
when: not mongodb_prometheus_exporter_enabled
|
|
tags: [ 'mongodb', 'prometheus', 'mongodb_prometheus' ]
|