automaticaly get release version from github

This commit is contained in:
Ludovic Cartier 2021-05-26 18:23:12 +02:00
parent 649b7b8f00
commit be04f2d74f
5 changed files with 109 additions and 93 deletions

View File

@ -1,5 +1 @@
---
prometheus_node_exporter_version: '1.1.2'
prometheus_mysqld_exporter_version: '0.12.1'
prometheus_postgres_exporter_version: '0.9.0'
prometheus_mongodb_exporter_version: '0.20.4'

View File

@ -1,4 +1,31 @@
---
- name: 'prometheus | mongodb exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/percona/mongodb_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
register: prometheus_mongodb_exporter_version
run_once: true
- name: 'prometheus | mongodb exporter | download'
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
dest: /tmp
- name: 'prometheus | mongodb exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version.stdout }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | mongodb exporter | move to /usr/local/bin'
copy:
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_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'
- name: 'prometheus | mongodb exporter | install unit file to systemd'
template:
src: systemd/prometheus-mongodb-exporter.service.j2
@ -11,29 +38,8 @@
systemd:
daemon_reload: yes
enabled: yes
state: started
name: prometheus-mongodb-exporter.service
- name: 'prometheus | mongodb exporter | download'
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
- name: 'prometheus | mongodb exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | mongodb exporter | move to /usr/local/bin'
copy:
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version }}.linux-amd64/mongodb_exporter
dest: /usr/local/bin/prometheus-mongodb-exporter
remote_src: yes
owner: root
group: root
mode: 0755
- name: 'prometheus | mongodb exporter | configuration'
template:
src: prometheus-mongodb-exporter.conf.j2
@ -43,4 +49,3 @@
mode: 0600
notify:
- 'prometheus | mongodb exporter | restart service'

View File

@ -1,4 +1,31 @@
---
- name: 'prometheus | mysqld exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/prometheus/mysqld_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
register: prometheus_mysqld_exporter_version
run_once: true
- name: 'prometheus | mysqld exporter | download'
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
dest: /tmp
- name: 'prometheus | mysqld exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version.stdout }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | mysqld exporter | move to /usr/local/bin'
copy:
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version.stdout }}.linux-amd64/mysqld_exporter
dest: /usr/local/bin/prometheus-mysqld-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | mysqld exporter | restart service'
- name: 'prometheus | mysqld exporter | install unit file to systemd'
template:
src: systemd/prometheus-mysqld-exporter.service.j2
@ -13,26 +40,6 @@
enabled: yes
name: prometheus-mysqld-exporter.service
- name: 'prometheus | mysqld exporter | download'
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
- name: 'prometheus | mysqld exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | mysqld exporter | move to /usr/local/bin'
copy:
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version }}.linux-amd64/mysqld_exporter
dest: /usr/local/bin/prometheus-mysqld-exporter
remote_src: yes
owner: root
group: root
mode: 0755
- name: 'prometheus | mysqld exporter | configuration'
copy:
dest: '/var/lib/prometheus/.my.cnf'
@ -49,4 +56,3 @@
register: prometheus_mysqld_exporter_configuration
notify:
- 'prometheus | mysqld exporter | restart service'

View File

@ -1,4 +1,31 @@
---
- name: 'prometheus | node exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/prometheus/node_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
register: prometheus_node_exporter_version
run_once: true
- name: 'prometheus | node exporter | download'
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
dest: /tmp
- name: 'prometheus | node exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/node_exporter-{{ prometheus_node_exporter_version.stdout }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | node exporter | move to /usr/local/bin'
copy:
src: /tmp/node_exporter-{{ prometheus_node_exporter_version.stdout }}.linux-amd64/node_exporter
dest: /usr/local/bin/prometheus-node-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | node exporter | restart service'
- name: 'prometheus | node exporter | install unit file to systemd'
template:
src: systemd/prometheus-node-exporter.service.j2
@ -12,26 +39,3 @@
daemon_reload: yes
enabled: yes
name: prometheus-node-exporter.service
- name: 'prometheus | node exporter | download'
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
- name: 'prometheus | node exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/node_exporter-{{ prometheus_node_exporter_version }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | node exporter | move to /usr/local/bin'
copy:
src: /tmp/node_exporter-{{ prometheus_node_exporter_version }}.linux-amd64/node_exporter
dest: /usr/local/bin/prometheus-node-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | node exporter | restart service'

View File

@ -1,4 +1,31 @@
---
- name: 'prometheus | postgres exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/prometheus-community/postgres_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
register: prometheus_postgres_exporter_version
run_once: true
- name: 'prometheus | postgres exporter | download'
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
dest: /tmp
- name: 'prometheus | postgres exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version.stdout }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | postgres exporter | move to /usr/local/bin'
copy:
src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version.stdout }}.linux-amd64/postgres_exporter
dest: /usr/local/bin/prometheus-postgres-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | postgres exporter | restart service'
- name: 'prometheus | postgres exporter | install unit file to systemd'
template:
src: systemd/prometheus-postgres-exporter.service.j2
@ -7,7 +34,6 @@
group: root
mode: 0600
- name: 'prometheus | postgres exporter | configure systemd to use service'
systemd:
daemon_reload: yes
@ -15,26 +41,6 @@
state: started
name: prometheus-postgres-exporter.service
- name: 'prometheus | postgres exporter | download'
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
- name: 'prometheus | postgres exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version }}.linux-amd64.tar.gz
dest: /tmp
- name: 'prometheus | postgres exporter | move to /usr/local/bin'
copy:
src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version }}.linux-amd64/postgres_exporter
dest: /usr/local/bin/prometheus-postgres-exporter
remote_src: yes
owner: root
group: root
mode: 0755
- name: 'prometheus | postgres exporter | configuration'
copy:
dest: '/etc/default/prometheus-postgres-exporter'
@ -53,4 +59,3 @@
register: prometheu_postgres_exporter_configuration
notify:
- 'prometheus | postgres exporter | restart service'