update exporter conf for mongoDB and mysql

This commit is contained in:
Ludovic Cartier 2021-05-31 16:23:19 +02:00
parent 78bceb35f7
commit e51e4ce7a0
6 changed files with 21 additions and 25 deletions

View File

@ -53,18 +53,18 @@
notify:
- 'prometheus | mongodb exporter | restart service'
- name: 'prometheus | mongodb exporter | configuration'
template:
src: conf/mongodb-exporter.conf.j2
dest: /etc/mongodb-exporter.conf
owner: root
group: root
mode: 0600
notify:
- 'prometheus | mongodb exporter | restart service'
- name: 'prometheus | mongodb exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-mongodb-exporter.service
- name: 'prometheus | mongodb exporter | configuration'
template:
src: conf/prometheus-mongodb-exporter.j2
dest: /etc/default/prometheus-mongodb-exporter
owner: root
group: root
mode: 0600
notify:
- 'prometheus | mongodb exporter | restart service'

View File

@ -44,20 +44,12 @@
name: prometheus-postgres-exporter.service
- name: 'prometheus | postgres exporter | configuration'
copy:
dest: '/etc/default/prometheus-postgres-exporter'
template:
src: conf/prometheus-postgres-exporter.j2
dest: /etc/default/prometheus-postgres-exporter
owner: root
group: root
mode: 0644
backup: yes
content: |
DATA_SOURCE_NAME='postgresql://{{ prometheus_exporter_postgresql_user }}:{{ prometheus_exporter_postgresql_password }}@{{ prometheus_exporter_postgresql_host }}:{{prometheus_exporter_postgresql_port }}/''
ARGS=''
when:
- prometheus_postgres_exporter_user is defined
- prometheus_postgres_exporter_password is defined
- prometheus_postgres_exporter_host is defined
- prometheus_postgres_exporter_port is defined
mode: 0600
register: prometheu_postgres_exporter_configuration
notify:
- 'prometheus | postgres exporter | restart service'

View File

@ -0,0 +1,2 @@
# {{ ansible_managed }}
DATA_SOURCE_NAME="user={{ prometheus_postgres_exporter_user|default("postgres") }} host={{ prometheus_postgres_exporter_host|default("/var/run/postgresql/") }} sslmode={{ prometheus_postgres_exporter_sslmode|default("disable") }}"

View File

@ -5,7 +5,7 @@ After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/prometheus-mongodb-exporter
EnvironmentFile=/etc/mongodb-exporter.conf
EnvironmentFile=/etc/default/prometheus-mongodb-exporter
[Install]
WantedBy=multi-user.target

View File

@ -4,7 +4,9 @@ After=network.target
[Service]
Type=simple
User={{ prometheus_postgres_exporter_user|default("postgres") }}
ExecStart=/usr/local/bin/prometheus-postgres-exporter
EnvironmentFile=/etc/default/prometheus-postgres-exporter
[Install]
WantedBy=multi-user.target