From f4e377508ae0264f8353e4219400a1903fd82bc7 Mon Sep 17 00:00:00 2001 From: Ludovic Cartier Date: Wed, 26 May 2021 10:46:57 +0200 Subject: [PATCH] move exporter to list --- tasks/main.yml | 13 ++++--------- tasks/mongodb_exporter.yml | 5 ----- tasks/mysqld_exporter.yml | 5 ----- tasks/node_exporter.yml | 5 ----- tasks/postgresql_exporter.yml | 7 ------- 5 files changed, 4 insertions(+), 31 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 5036055..118ba24 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,24 +11,19 @@ - name: 'prometheus | Node exporter' include_tasks: 'node_exporter.yml' when: - - prometheus_node_exporter_enable is defined - - prometheus_node_exporter_enable == "true" + - "'node' in {{ prometheus_exporter_packages }}" - name: 'prometheus | MongoDB exporter' include_tasks: 'mongodb_exporter.yml' when: - - prometheus_mongodb_exporter_enable is defined - - prometheus_mongodb_exporter_enable == "true" + - "'mongodb' in {{ prometheus_exporter_packages }}" - name: 'prometheus | MySQL exporter' include_tasks: 'mysqld_exporter.yml' when: - - prometheus_mysqld_exporter_enable is defined - - prometheus_mysqld_exporter_enable == "true" + - "'mysql' in {{ prometheus_exporter_packages }}" - name: 'prometheus | PostgreSQL exporter' include_tasks: 'postgresql_exporter.yml' when: - - prometheus_postgres_exporter_enable is defined - - prometheus_postgres_exporter_enable == "true" - + - "'postgresql' in {{ prometheus_exporter_packages }}" diff --git a/tasks/mongodb_exporter.yml b/tasks/mongodb_exporter.yml index afeb897..89e11c2 100644 --- a/tasks/mongodb_exporter.yml +++ b/tasks/mongodb_exporter.yml @@ -3,14 +3,12 @@ get_url: url: https://github.com/percona/mongodb_exporter/releases/download/v{{ prometheus_mongodb_exporter_version }}/mongodb_exporter-{{ prometheus_mongodb_exporter_version }}.linux-amd64.tar.gz dest: /tmp - when: prometheus_mongodb_exporter_enable == "true" - name: 'prometheus | mongodb exporter | unarchive' unarchive: remote_src: yes src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version }}.linux-amd64.tar.gz dest: /tmp - when: prometheus_mongodb_exporter_enable == "true" - name: 'prometheus | mongodb exporter | move to /usr/local/bin' copy: @@ -20,7 +18,6 @@ owner: root group: root mode: 0755 - when: prometheus_mongodb_exporter_enable == "true" - name: 'prometheus | mongodb exporter | install unit file to systemd' template: @@ -29,7 +26,6 @@ owner: root group: root mode: 0600 - when: prometheus_mongodb_exporter_enable == "true" - name: 'prometheus | mongodb exporter | configure systemd to use service' systemd: @@ -37,4 +33,3 @@ enabled: yes state: started name: prometheus-mongodb-exporter.service - when: prometheus_mongodb_exporter_enable == "true" diff --git a/tasks/mysqld_exporter.yml b/tasks/mysqld_exporter.yml index 6dac399..1b69a66 100644 --- a/tasks/mysqld_exporter.yml +++ b/tasks/mysqld_exporter.yml @@ -3,7 +3,6 @@ get_url: url: https://github.com/prometheus/mysqld_exporter/releases/download/v{{ prometheus_mysqld_exporter_version }}/mysqld_exporter-{{ prometheus_mysqld_exporter_version }}.linux-amd64.tar.gz dest: /tmp - when: prometheus_mysqld_exporter_enable == "true" - name: 'prometheus | mysqld exporter | unarchive' unarchive: @@ -20,7 +19,6 @@ owner: root group: root mode: 0755 - when: prometheus_mysqld_exporter_enable == "true" - name: 'prometheus | mysqld exporter | configuration' copy: @@ -35,7 +33,6 @@ password={{ prometheus_mysqld_exporter_password }} when: - prometheus_mysqld_exporter_user is defined - - prometheus_mysqld_exporter_enable == "true" register: prometheus_mysqld_exporter_configuration - name: 'prometheus | mysqld exporter | install unit file to systemd' @@ -45,7 +42,6 @@ owner: root group: root mode: 0600 - when: prometheus_mysqld_exporter_enable == "true" - name: 'prometheus | mysqld exporter | configure systemd to use service' systemd: @@ -53,4 +49,3 @@ enabled: yes state: started name: prometheus-mysqld-exporter.service - when: prometheus_mysqld_exporter_enable == "true" diff --git a/tasks/node_exporter.yml b/tasks/node_exporter.yml index 754d318..2e0274d 100644 --- a/tasks/node_exporter.yml +++ b/tasks/node_exporter.yml @@ -3,14 +3,12 @@ get_url: url: https://github.com/prometheus/node_exporter/releases/download/v{{ prometheus_node_exporter_version }}/node_exporter-{{ prometheus_node_exporter_version }}.linux-amd64.tar.gz dest: /tmp - when: prometheus_node_exporter_enable == "true" - name: 'prometheus | node exporter | unarchive' unarchive: remote_src: yes src: /tmp/node_exporter-{{ prometheus_node_exporter_version }}.linux-amd64.tar.gz dest: /tmp - when: prometheus_node_exporter_enable == "true" - name: 'prometheus | node exporter | move to /usr/local/bin' copy: @@ -20,7 +18,6 @@ owner: root group: root mode: 0755 - when: prometheus_node_exporter_enable == "true" - name: 'prometheus | node exporter | install unit file to systemd' template: @@ -29,7 +26,6 @@ owner: root group: root mode: 0600 - when: prometheus_node_exporter_enable == "true" - name: 'prometheus | node exporter | configure systemd to use service' systemd: @@ -37,4 +33,3 @@ enabled: yes state: started name: prometheus-node-exporter.service - when: prometheus_node_exporter_enable == "true" diff --git a/tasks/postgresql_exporter.yml b/tasks/postgresql_exporter.yml index 2aef4b7..a63b2f9 100644 --- a/tasks/postgresql_exporter.yml +++ b/tasks/postgresql_exporter.yml @@ -3,14 +3,12 @@ get_url: url: https://github.com/prometheus-community/postgres_exporter/releases/download/v{{ prometheus_postgres_exporter_version }}/postgres_exporter-{{ prometheus_postgres_exporter_version }}.linux-amd64.tar.gz dest: /tmp - when: prometheus_postgres_exporter_enable == "true" - name: 'prometheus | postgres exporter | unarchive' unarchive: remote_src: yes src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version }}.linux-amd64.tar.gz dest: /tmp - when: prometheus_postgres_exporter_enable == "true" - name: 'prometheus | postgres exporter | move to /usr/local/bin' copy: @@ -20,7 +18,6 @@ owner: root group: root mode: 0755 - when: prometheus_postgres_exporter_enable == "true" - name: 'prometheus | postgres exporter | configuration' copy: @@ -34,7 +31,6 @@ user={{ prometheus_postgres_exporter_user }} password={{ prometheus_postgres_exporter_password }} when: - - prometheus_postgres_exporter_user is defined - prometheus_postgres_exporter_enable == "true" register: prometheus_postgres_exporter_configuration @@ -53,7 +49,6 @@ - prometheus_postgres_exporter_password is defined - prometheus_postgres_exporter_host is defined - prometheus_postgres_exporter_port is defined - - prometheus_postgres_exporter_enable == "true" register: prometheu_postgres_exporter_configuration - name: 'prometheus | postgres exporter | install unit file to systemd' @@ -63,7 +58,6 @@ owner: root group: root mode: 0600 - when: prometheus_postgres_exporter_enable == "true" - name: 'prometheus | postgres exporter | configure systemd to use service' @@ -72,4 +66,3 @@ enabled: yes state: started name: prometheus-postgres-exporter.service - when: prometheus_postgres_exporter_enable == "true"