add custom exporter's version support

This commit is contained in:
Ludovic Cartier 2021-05-31 15:42:33 +02:00
parent f86870ec3a
commit daac4303b0
4 changed files with 30 additions and 15 deletions

View File

@ -3,23 +3,23 @@
shell: curl --silent "https://api.github.com/repos/percona/mongodb_exporter/releases/latest" | jq -r .tag_name | sed "s/v//" shell: curl --silent "https://api.github.com/repos/percona/mongodb_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
args: args:
warn: false warn: false
register: prometheus_mongodb_exporter_version register: prometheus_mongodb_exporter_latest_version
run_once: true run_once: true
- name: 'prometheus | mongodb exporter | download' - name: 'prometheus | mongodb exporter | download'
get_url: get_url:
url: https://github.com/percona/mongodb_exporter/releases/download/v{{ prometheus_mongodb_exporter_version.stdout }}/mongodb_exporter-{{ prometheus_mongodb_exporter_version.stdout }}.linux-amd64.tar.gz url: https://github.com/percona/mongodb_exporter/releases/download/v{{ prometheus_mongodb_exporter_version|default(prometheus_mongodb_exporter_latest_version.stdout) }}/mongodb_exporter-{{ prometheus_mongodb_exporter_version|default(prometheus_mongodb_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp dest: /tmp
- name: 'prometheus | mongodb exporter | unarchive' - name: 'prometheus | mongodb exporter | unarchive'
unarchive: unarchive:
remote_src: yes remote_src: yes
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version.stdout }}.linux-amd64.tar.gz src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version|default(prometheus_mongodb_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp dest: /tmp
- name: 'prometheus | mongodb exporter | move to /usr/local/bin' - name: 'prometheus | mongodb exporter < v0.2 | move to /usr/local/bin'
copy: copy:
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version.stdout }}.linux-amd64/mongodb_exporter src: /tmp/mongodb_exporter
dest: /usr/local/bin/prometheus-mongodb-exporter dest: /usr/local/bin/prometheus-mongodb-exporter
remote_src: yes remote_src: yes
owner: root owner: root
@ -27,6 +27,21 @@
mode: 0755 mode: 0755
notify: notify:
- 'prometheus | mongodb exporter | restart service' - 'prometheus | mongodb exporter | restart service'
when:
- prometheus_mongodb_exporter_version < '0.2'
- name: 'prometheus | mongodb exporter > v0.2 | move to /usr/local/bin'
copy:
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version|default(prometheus_mongodb_exporter_latest_version.stdout) }}.linux-amd64/mongodb_exporter
dest: /usr/local/bin/prometheus-mongodb-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | mongodb exporter | restart service'
when:
- prometheus_mongodb_exporter_version > '0.2'
- name: 'prometheus | mongodb exporter | install unit file to systemd' - name: 'prometheus | mongodb exporter | install unit file to systemd'
template: template:

View File

@ -3,23 +3,23 @@
shell: curl --silent "https://api.github.com/repos/prometheus/mysqld_exporter/releases/latest" | jq -r .tag_name | sed "s/v//" shell: curl --silent "https://api.github.com/repos/prometheus/mysqld_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
args: args:
warn: false warn: false
register: prometheus_mysqld_exporter_version register: prometheus_mysqld_exporter_latest_version
run_once: true run_once: true
- name: 'prometheus | mysqld exporter | download' - name: 'prometheus | mysqld exporter | download'
get_url: get_url:
url: https://github.com/prometheus/mysqld_exporter/releases/download/v{{ prometheus_mysqld_exporter_version.stdout }}/mysqld_exporter-{{ prometheus_mysqld_exporter_version.stdout }}.linux-amd64.tar.gz url: https://github.com/prometheus/mysqld_exporter/releases/download/v{{ prometheus_mysqld_exporter_version|default(prometheus_mysqld_exporter_latest_version.stdout) }}/mysqld_exporter-{{ prometheus_mysqld_exporter_version.|default(prometheus_mysqld_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp dest: /tmp
- name: 'prometheus | mysqld exporter | unarchive' - name: 'prometheus | mysqld exporter | unarchive'
unarchive: unarchive:
remote_src: yes remote_src: yes
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version.stdout }}.linux-amd64.tar.gz src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version|default(prometheus_mysqld_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp dest: /tmp
- name: 'prometheus | mysqld exporter | move to /usr/local/bin' - name: 'prometheus | mysqld exporter | move to /usr/local/bin'
copy: copy:
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version.stdout }}.linux-amd64/mysqld_exporter src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version|default(prometheus_mysqld_exporter_latest_version.stdout) }}.linux-amd64/mysqld_exporter
dest: /usr/local/bin/prometheus-mysqld-exporter dest: /usr/local/bin/prometheus-mysqld-exporter
remote_src: yes remote_src: yes
owner: root owner: root

View File

@ -8,18 +8,18 @@
- name: 'prometheus | node exporter | download' - name: 'prometheus | node exporter | download'
get_url: get_url:
url: https://github.com/prometheus/node_exporter/releases/download/v{{ prometheus_node_exporter_version.stdout }}/node_exporter-{{ prometheus_node_exporter_version.stdout }}.linux-amd64.tar.gz url: https://github.com/prometheus/node_exporter/releases/download/v{{ prometheus_node_exporter_version|default(prometheus_node_exporter_latest_version.stdout) }}/node_exporter-{{ prometheus_node_exporter_version|default(prometheus_node_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp dest: /tmp
- name: 'prometheus | node exporter | unarchive' - name: 'prometheus | node exporter | unarchive'
unarchive: unarchive:
remote_src: yes remote_src: yes
src: /tmp/node_exporter-{{ prometheus_node_exporter_version.stdout }}.linux-amd64.tar.gz src: /tmp/node_exporter-{{ prometheus_node_exporter_version|default(prometheus_node_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp dest: /tmp
- name: 'prometheus | node exporter | move to /usr/local/bin' - name: 'prometheus | node exporter | move to /usr/local/bin'
copy: copy:
src: /tmp/node_exporter-{{ prometheus_node_exporter_version.stdout }}.linux-amd64/node_exporter src: /tmp/node_exporter-{{ prometheus_node_exporter_version|default(prometheus_node_exporter_latest_version.stdout) }}.linux-amd64/node_exporter
dest: /usr/local/bin/prometheus-node-exporter dest: /usr/local/bin/prometheus-node-exporter
remote_src: yes remote_src: yes
owner: root owner: root

View File

@ -8,18 +8,18 @@
- name: 'prometheus | postgres exporter | download' - name: 'prometheus | postgres exporter | download'
get_url: get_url:
url: https://github.com/prometheus-community/postgres_exporter/releases/download/v{{ prometheus_postgres_exporter_version.stdout }}/postgres_exporter-{{ prometheus_postgres_exporter_version.stdout }}.linux-amd64.tar.gz url: https://github.com/prometheus-community/postgres_exporter/releases/download/v{{ prometheus_postgres_exporter_version|default(prometheus_postgres_exporter_latest_version.stdout) }}/postgres_exporter-{{ prometheus_postgres_exporter_version|default(prometheus_postgres_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp dest: /tmp
- name: 'prometheus | postgres exporter | unarchive' - name: 'prometheus | postgres exporter | unarchive'
unarchive: unarchive:
remote_src: yes remote_src: yes
src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version.stdout }}.linux-amd64.tar.gz src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version|default(prometheus_postgres_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp dest: /tmp
- name: 'prometheus | postgres exporter | move to /usr/local/bin' - name: 'prometheus | postgres exporter | move to /usr/local/bin'
copy: copy:
src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version.stdout }}.linux-amd64/postgres_exporter src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version|default(prometheus_postgres_exporter_latest_version.stdout) }}.linux-amd64/postgres_exporter
dest: /usr/local/bin/prometheus-postgres-exporter dest: /usr/local/bin/prometheus-postgres-exporter
remote_src: yes remote_src: yes
owner: root owner: root