diff --git a/tasks/mysqld_exporter.yml b/tasks/mysqld_exporter.yml index 13de1f3..b8df914 100644 --- a/tasks/mysqld_exporter.yml +++ b/tasks/mysqld_exporter.yml @@ -42,25 +42,13 @@ enabled: yes name: prometheus-mysqld-exporter.service -- name: 'prometheus | mysqld exporter | create configuration directory' - file: - path: /var/lib/prometheus - state: directory - mode: '0755' - tags: - - prometheus - - name: 'prometheus | mysqld exporter | configuration' - copy: - dest: '/var/lib/prometheus/.my.cnf' + template: + src: conf/prometheus-mysqld-exporter.j2 + dest: /etc/default/prometheus-mysqld-exporter owner: root group: root - mode: 0644 - backup: yes - content: | - [client] - user={{ prometheus_mysqld_exporter_user }} - password={{ prometheus_mysqld_exporter_password }} + mode: 0600 when: - prometheus_mysqld_exporter_user is defined register: prometheus_mysqld_exporter_configuration diff --git a/templates/conf/prometheus-mysqld-exporter.j2 b/templates/conf/prometheus-mysqld-exporter.j2 new file mode 100644 index 0000000..f04d436 --- /dev/null +++ b/templates/conf/prometheus-mysqld-exporter.j2 @@ -0,0 +1,4 @@ +# {{ ansible_managed }} +[client] +user={{ prometheus_mysqld_exporter_user }} +password={{ prometheus_mysqld_exporter_password }} diff --git a/templates/systemd/prometheus-mysqld-exporter.service.j2 b/templates/systemd/prometheus-mysqld-exporter.service.j2 index bfee56c..1246bc8 100644 --- a/templates/systemd/prometheus-mysqld-exporter.service.j2 +++ b/templates/systemd/prometheus-mysqld-exporter.service.j2 @@ -5,7 +5,7 @@ After=network.target [Service] Type=simple ExecStart=/usr/local/bin/prometheus-mysqld-exporter \ ---config.my-cnf /var/lib/prometheus/.my.cnf \ +--config.my-cnf /etc/default/prometheus-mysqld-exporter \ --collect.global_status \ --collect.info_schema.innodb_metrics \ --collect.auto_increment.columns \