add new exporters binaries source

This commit is contained in:
tom.chivert 2023-07-20 11:47:31 +02:00
parent 681b7b2d72
commit 902af9c58d
2 changed files with 40 additions and 6 deletions

View File

@ -26,6 +26,11 @@ prometheus_repo_postgres: prometheus-community
prometheus_repo_redis: tchivert
prometheus_repo_varnish: tchivert
prometheus_exporters_repo: "https://git.rznet.fr/tchivert/prometheus_exporters"
prometheus_exporters_release: "latest"
prometheus_exporters_sources: "repo"
# prometheus_exporters_sources: "origin"
## server
prometheus_nodes_ip:
localhost: "127.0.0.1"

View File

@ -28,26 +28,48 @@
when: exporter_upgrade == "yes"
tags: [ 'prometheus_{{ exporter }}' ]
# If prometheus_exporters_sources == "repo"
- name: '{{ exporter }} exporter | download from repo'
get_url:
url: "{{prometheus_exporters_repo}}/releases/download/{{prometheus_exporters_release}}/{{exporter}}_exporter"
dest: /usr/local/bin/prometheus-{{ exporter }}-exporter
remote_src: yes
owner: root
group: root
mode: 0755
ignore_errors: '{{ ansible_check_mode }}'
when: >
(not stat_result.stat.exists or exporter_upgrade == "yes") and
prometheus_exporters_sources == "repo"
tags: [ 'prometheus_{{ exporter }}' ]
# If prometheus_exporters_sources == "origin"
- name: '{{ exporter }} exporter | create temp path'
file:
state: directory
path: /tmp/prometheus_exporter/{{ exporter }}
when: not stat_result.stat.exists or exporter_upgrade == "yes"
when: >
not stat_result.stat.exists or exporter_upgrade == "yes"
prometheus_exporters_sources == "origin"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/{{ prometheus_repo }}/{{ exporter }}_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
register: prometheus_exporter_latest_version
run_once: true
when: not stat_result.stat.exists or exporter_upgrade == "yes"
when: >
(not stat_result.stat.exists or exporter_upgrade == "yes") and
prometheus_exporters_sources == "origin"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | download'
- name: '{{ exporter }} exporter | download from origin'
get_url:
url: "https://github.com/{{ prometheus_repo }}/{{ exporter }}_exporter/releases/download/v{{ prometheus_exporter_latest_version.stdout }}/{{ exporter }}_exporter-{{ prometheus_exporter_latest_version.stdout }}.{{ prometheus_os }}-{{ prometheus_arch }}.tar.gz"
dest: /tmp/prometheus_exporter/{{ exporter }}/
ignore_errors: '{{ ansible_check_mode }}'
when: not stat_result.stat.exists or exporter_upgrade == "yes"
when: >
(not stat_result.stat.exists or exporter_upgrade == "yes") and
prometheus_exporters_sources == "origin"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | unarchive'
@ -55,7 +77,9 @@
remote_src: yes
src: /tmp/prometheus_exporter/{{ exporter }}/{{ exporter }}_exporter-{{ prometheus_exporter_latest_version.stdout }}.{{ prometheus_os }}-{{ prometheus_arch }}.tar.gz
dest: /tmp/prometheus_exporter/{{ exporter }}/
when: not stat_result.stat.exists or exporter_upgrade == "yes"
when: >
(not stat_result.stat.exists or exporter_upgrade == "yes") and
prometheus_exporters_sources == "origin"
ignore_errors: '{{ ansible_check_mode }}'
tags: [ 'prometheus_{{ exporter }}' ]
@ -69,7 +93,9 @@
mode: 0755
notify:
- '{{ exporter }}-exporter-restart'
when: not stat_result.stat.exists or exporter_upgrade == "yes"
when: >
(not stat_result.stat.exists or exporter_upgrade == "yes") and
prometheus_exporters_sources == "origin"
tags: [ 'prometheus_{{ exporter }}' ]
ignore_errors: '{{ ansible_check_mode }}'
@ -77,6 +103,9 @@
file:
state: absent
path: /tmp/prometheus_exporter/{{ exporter }}
when: >
(not stat_result.stat.exists or exporter_upgrade == "yes") and
prometheus_exporters_sources == "origin"
- name: '{{ exporter }} exporter | systemd | copy unit file'
template: