big refacto - might have break things

This commit is contained in:
Ludovic Cartier 2022-11-11 23:51:52 +01:00
parent 92d32702ee
commit 22c2c39818
17 changed files with 196 additions and 524 deletions

View File

@ -4,10 +4,32 @@ prometheus
The present role :
- installs prometheus server inside a Docker container
- installs various prometheus exporter
- node
- blackbox
- apache
- varnish
- php-fpm
- opcache
- redis
- memcached
- mysql
- postgres
- mongodb
It has been tested on :
Please note that Docker and Haproxy their own embedded exporters.
- https://docs.docker.com/config/daemon/prometheus/
- https://www.haproxy.com/fr/blog/haproxy-exposes-a-prometheus-metrics-endpoint/
The role has been successfully tested on :
- Debian 9
- Debian 10
- Debian 11
Forced upgrade of installed exporters can be done by setting the extra parameters "exporter_upgrade" to "yes".
```
ansible-playbook playbook/myhost.yml -t prometheus -e "exporter_upgrade=yes"
```
Role variables
--------------
@ -79,11 +101,14 @@ Example variables
TODO
----
- add options to memcacged exporter launch
- --memcached.address="localhost:11211"
- --memcached.timeout=1s
- --memcached.pid-file=""
- handle multi instances for memcached exporter
- documentation
- review / enhance documentation
- memcached
- add options to exporter launch
- --memcached.address="localhost:11211"
- --memcached.timeout=1s
- --memcached.pid-file=""
- handle multi instances for memcached exporter
License
-------

View File

@ -1,30 +1,29 @@
---
awh_services_docker_pull: "no"
prometheus_docker_pull: "no"
prometheus_apache_port: 8080
exporter_upgrade: ""
prometheus_exporter_packages: []
prometheus_os: "linux"
prometheus_arch: "amd64"
## repos url
prometheus_repo: ""
prometheus_repo_apache: Lusitaniae
prometheus_repo_blackbox: prometheus
prometheus_repo_memcached: prometheus
prometheus_repo_mongodb: percona
prometheus_repo_mysqld: prometheus
prometheus_repo_node: prometheus
prometheus_repo_opcache: MyOnlineStore
prometheus_repo_phpfpm: Lusitaniae
prometheus_repo_postgres: prometheus-community
prometheus_repo_redis: oliver006
prometheus_repo_varnish: jonnenauha
## server
prometheus_nodes_ip:
localhost: "127.0.0.1"
prometheus_mongodb_exporter_database: "admin"
prometheus_mongodb_exporter_host: "localhost"
prometheus_mongodb_exporter_port: 27017
prometheus_phpfpm_sockets_directory: "/run/php/"
prometheus_phpfpm_sockets_directory_additional: "/var/run/php*.sock"
prometheus_opcache_exporter_fcgi_uri: "unix:///var/run/www.sock"
prometheus_postgres_exporter_systemd_user: "postgres"
prometheus_postgres_exporter_host: "/var/run/postgresql/"
prometheus_postgres_exporter_sslmode: "disable"
prometheus_postgres_exporter_user: "postgres"
prometheus_postgres_exporter_password: "changeme_"
prometheus_postgres_exporter_port: 5432
prometheus_retention_time: "15d"
prometheus_server_enable: false
@ -35,8 +34,29 @@ prometheus_server_scrape_interval: 5
prometheus_server_scrape_timeout: 5
prometheus_server_version: "latest"
## exporter
prometheus_exporter_packages: []
prometheus_apache_port: 8080
prometheus_blackbox_exporter_host: localhost
prometheus_mongodb_exporter_database: "admin"
prometheus_mongodb_exporter_host: "localhost"
prometheus_mongodb_exporter_port: 27017
prometheus_opcache_exporter_fcgi_uri: "unix:///var/run/www.sock"
prometheus_phpfpm_sockets_directory: "/run/php/"
prometheus_phpfpm_sockets_directory_additional: "/var/run/php*.sock"
prometheus_postgres_exporter_systemd_user: "postgres"
prometheus_postgres_exporter_host: "/var/run/postgresql/"
prometheus_postgres_exporter_sslmode: "disable"
prometheus_postgres_exporter_user: "postgres"
prometheus_postgres_exporter_password: "changeme_"
prometheus_postgres_exporter_port: 5432
prometheus_redis_exporter_addr: "redis://localhost:6379"
prometheus_redis_exporter_user: ""
prometheus_redis_exporter_password: ""

View File

@ -1,6 +1,6 @@
---
prometheus_server_enable: 'true'
prometheus_server_monitor: 'wac'
prometheus_server_monitor: 'foo'
prometheus_exporter_packages:
- node
@ -8,55 +8,41 @@ prometheus_exporter_packages:
- apache
prometheus_node_exporter_targets:
# PPD
- preprod-server1
# PRD
- prod-server1
- prod-server2
prometheus_phpfpm_exporter_targets:
# PPD
- preprod-server1
# PRD
- prod-server1
- prod-server2
prometheus_apache_exporter_targets:
# PPD
- preprod-server1
# PRD
- prod-server1
- prod-server2
prometheus_haproxy_exporter_targets:
# PPD
- preprod-server1
# PRD
- prod-server1
- prod-server2
prometheus_varnish_exporter_targets:
# PPD
- preprod-server1
# PRD
- prod-server1
- prod-server2
prometheus_mysqld_exporter_targets:
# PPD
- preprod-server1
# PRD
- prod-server1
- prod-server2
prometheus_mysqld_exporter_custom:
# PPD
preprod-server1:
environment: 'preprod'
service_name: 'preprod'
cluster: 'preprod'
node_name: preprod-server1
# PRD
prod-server1:
environment: 'prod'
service_name: 'prod-bdd1'
@ -69,27 +55,21 @@ prometheus_mysqld_exporter_custom:
node_name: prod-server2
prometheus_redis_multi_instances_exporter_targets:
# PPD
- redis://preprod-server1:6379
- redis://preprod-server1:6380
- redis://preprod-server1:6381
- redis://preprod-server1:6382
# PROD
- redis://prod-server1:6379
- redis://prod-server2:6379
- redis://prod-server2:6380
prometheus_redis_exporter_targets:
# PPD
- preprod-server1
# PRD
- prod-server1
- prod-server2
prometheus_nodes_ip:
# PPD
preprod-server1 : 10.0.1.10
# PRD
prod-server1 : 10.0.1.11
prod-server2 : 10.0.1.12

View File

@ -0,0 +1,99 @@
---
# to build prometheus repo for another var: https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#when-should-i-use-also-how-to-interpolate-variables-or-dynamic-variable-names
- set_fact:
prometheus_repo: "{{ lookup('vars', 'prometheus_repo_' ~ exporter) }}"
#- name: debug
# debug:
# msg: "Repo: {{ prometheus_repo }}"
- name: '{{ exporter }} exporter | check if exporter is already install'
stat:
path: /usr/local/bin/prometheus-{{ exporter }}-exporter
register: stat_result
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | stop old version'
systemd:
name: prometheus-{{ exporter }}-exporter.service
state: stopped
when: exporter_upgrade == "yes"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | remove old version'
file:
path: /usr/local/bin/prometheus-{{ exporter }}-exporter
state: absent
when: exporter_upgrade == "yes"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | create temp path'
file:
state: directory
path: /tmp/prometheus_exporter/{{ exporter }}
when: not stat_result.stat.exists or exporter_upgrade == "yes"
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//"
args:
warn: false
register: prometheus_exporter_latest_version
run_once: true
when: not stat_result.stat.exists or exporter_upgrade == "yes"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | download'
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 }}/
when: not stat_result.stat.exists or exporter_upgrade == "yes"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | unarchive'
unarchive:
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"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | move to /usr/local/bin'
copy:
src: /tmp/prometheus_exporter/{{ exporter }}/{{ exporter }}_exporter-{{ prometheus_exporter_latest_version.stdout }}.{{ prometheus_os }}-{{ prometheus_arch }}/{{ exporter }}_exporter
dest: /usr/local/bin/prometheus-{{ exporter }}-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | {{ exporter }} exporter | restart service'
when: not stat_result.stat.exists or exporter_upgrade == "yes"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | cleanup temp path'
file:
state: absent
path: /tmp/prometheus_exporter/{{ exporter }}
- name: '{{ exporter }} exporter | systemd | copy unit file'
template:
src: systemd/prometheus-{{ exporter }}-exporter.service.j2
dest: /etc/systemd/system/prometheus-{{ exporter }}-exporter.service
owner: root
group: root
mode: 0600
notify:
- 'prometheus | {{ exporter }} exporter | restart service'
when: not stat_result.stat.exists or exporter_upgrade == "yes"
tags: [ 'prometheus_{{ exporter }}' ]
- name: '{{ exporter }} exporter | systemd | enable {{ exporter }}'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-{{ exporter }}-exporter.service
ignore_errors: '{{ ansible_check_mode }}'
when: not stat_result.stat.exists or exporter_upgrade == "yes"
tags: [ 'prometheus_{{ exporter }}' ]

View File

@ -1,43 +1,3 @@
---
- name: 'apache exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/Lusitaniae/apache_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
args:
warn: false
register: prometheus_apache_exporter_latest_version
run_once: true
- name: 'apache exporter | download'
get_url:
url: https://github.com/Lusitaniae/apache_exporter/releases/download/v{{ prometheus_apache_exporter_version|default(prometheus_apache_exporter_latest_version.stdout) }}/apache_exporter-{{ prometheus_apache_exporter_version|default(prometheus_apache_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'apache exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/apache_exporter-{{ prometheus_apache_exporter_version|default(prometheus_apache_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'apache exporter | move to /usr/local/bin'
copy:
src: /tmp/apache_exporter-{{ prometheus_apache_exporter_version|default(prometheus_apache_exporter_latest_version.stdout) }}.linux-amd64/apache_exporter
dest: /usr/local/bin/prometheus-apache-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | apache exporter | restart service'
- name: 'apache exporter | install unit file to systemd'
template:
src: systemd/prometheus-apache-exporter.service.j2
dest: /etc/systemd/system/prometheus-apache-exporter.service
owner: root
group: root
mode: 0600
- name: 'prometheus | apache exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-apache-exporter.service
- include_tasks: _common.yml
tags: ['prometheus_apache']

View File

@ -1,32 +1,6 @@
---
- name: 'blackbox exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/prometheus/blackbox_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
args:
warn: false
register: prometheus_blackbox_exporter_latest_version
run_once: true
- name: 'blackbox exporter | download'
get_url:
url: https://github.com/prometheus/blackbox_exporter/releases/download/v{{ prometheus_blackbox_exporter_version|default(prometheus_blackbox_exporter_latest_version.stdout) }}/blackbox_exporter-{{ prometheus_blackbox_exporter_version|default(prometheus_blackbox_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'blackbox exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/blackbox_exporter-{{ prometheus_blackbox_exporter_version|default(prometheus_blackbox_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'blackbox exporter | move to /usr/local/bin'
copy:
src: /tmp/blackbox_exporter-{{ prometheus_blackbox_exporter_version|default(prometheus_blackbox_exporter_latest_version.stdout) }}.linux-amd64/blackbox_exporter
dest: /usr/local/bin/prometheus-blackbox-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | blackbox exporter | restart service'
- include_tasks: _common.yml
tags: ['prometheus_blackbox']
- name: 'blackbox exporter | configuration'
template:
@ -38,19 +12,3 @@
register: prometheus_blackbox_exporter_configuration
notify:
- 'prometheus | blackbox exporter | restart service'
- name: 'blackbox exporter | install unit file to systemd'
template:
src: systemd/prometheus-blackbox-exporter.service.j2
dest: /etc/systemd/system/prometheus-blackbox-exporter.service
owner: root
group: root
mode: 0600
notify:
- 'prometheus | blackbox exporter | restart service'
- name: 'blackbox exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-blackbox-exporter.service

View File

@ -1,56 +1,3 @@
---
- name: 'memcached exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/prometheus/memcached_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
args:
warn: false
register: prometheus_memcached_exporter_latest_version
run_once: true
- name: 'prometheus | memcached exporter | download'
get_url:
url: https://github.com/prometheus/memcached_exporter/releases/download/v{{ prometheus_memcached_exporter_version|default(prometheus_memcached_exporter_latest_version.stdout) }}/memcached_exporter-{{ prometheus_memcached_exporter_version|default(prometheus_memcached_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'memcached exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/memcached_exporter-{{ prometheus_memcached_exporter_version|default(prometheus_memcached_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'memcached exporter | move to /usr/local/bin'
copy:
src: /tmp/memcached_exporter-{{ prometheus_memcached_exporter_version|default(prometheus_memcached_exporter_latest_version.stdout) }}.linux-amd64/memcached_exporter
dest: /usr/local/bin/prometheus-memcached-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | memcached exporter | restart service'
- name: 'memcached exporter | install unit file to systemd'
template:
src: systemd/prometheus-memcached-exporter.service.j2
dest: /etc/systemd/system/prometheus-memcached-exporter.service
owner: root
group: root
mode: 0600
notify:
- 'prometheus | memcached exporter | restart service'
# - name: 'memcached exporter | configuration'
# template:
# src: conf/prometheus-memcached-exporter.j2
# dest: /etc/default/prometheus-memcached-exporter
# owner: root
# group: root
# mode: 0600
# register: prometheus_memcached_exporter_configuration
# notify:
# - 'prometheus | memcached exporter | restart service'
- name: 'memcached exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-memcached-exporter.service
- include_tasks: _common.yml
tags: ['prometheus_memcached']

View File

@ -1,21 +1,6 @@
---
- name: '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//"
args:
warn: false
register: prometheus_mongodb_exporter_latest_version
run_once: true
- name: 'mongodb exporter | download'
get_url:
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
- name: 'mongodb exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/mongodb_exporter-{{ prometheus_mongodb_exporter_version|default(prometheus_mongodb_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- include_tasks: _common.yml
tags: ['prometheus_mongodb']
- name: 'mongodb exporter < v0.2 | move to /usr/local/bin'
copy:
@ -30,19 +15,6 @@
when:
- prometheus_mongodb_exporter_latest_version.stdout < '0.2'
- name: '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_latest_version.stdout > '0.2'
- name: 'mongodb exporter | configuration'
template:
src: conf/prometheus-mongodb-exporter.j2
@ -52,19 +24,3 @@
mode: 0600
notify:
- 'prometheus | mongodb exporter | restart service'
- name: 'mongodb exporter | install unit file to systemd'
template:
src: systemd/prometheus-mongodb-exporter.service.j2
dest: /etc/systemd/system/prometheus-mongodb-exporter.service
owner: root
group: root
mode: 0600
notify:
- 'prometheus | mongodb exporter | restart service'
- name: 'mongodb exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-mongodb-exporter.service

View File

@ -1,32 +1,6 @@
---
- name: '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//"
args:
warn: false
register: prometheus_mysqld_exporter_latest_version
run_once: true
- name: 'mysqld exporter | download'
get_url:
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
- name: 'mysqld exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/mysqld_exporter-{{ prometheus_mysqld_exporter_version|default(prometheus_mysqld_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'mysqld exporter | move to /usr/local/bin'
copy:
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
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | mysqld exporter | restart service'
- include_tasks: _common.yml
tags: ['prometheus_mysqld']
- name: 'mysqld exporter | configuration'
template:
@ -40,17 +14,3 @@
register: prometheus_mysqld_exporter_configuration
notify:
- 'prometheus | mysqld exporter | restart service'
- name: 'mysqld exporter | install unit file to systemd'
template:
src: systemd/prometheus-mysqld-exporter.service.j2
dest: /etc/systemd/system/prometheus-mysqld-exporter.service
owner: root
group: root
mode: 0600
- name: 'mysqld exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-mysqld-exporter.service

View File

@ -1,43 +1,3 @@
---
- name: '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//"
args:
warn: false
register: prometheus_node_exporter_latest_version
run_once: true
- name: 'node exporter | download'
get_url:
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
- name: 'node exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/node_exporter-{{ prometheus_node_exporter_version|default(prometheus_node_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'node exporter | move to /usr/local/bin'
copy:
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
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | node exporter | restart service'
- name: 'node exporter | install unit file to systemd'
template:
src: systemd/prometheus-node-exporter.service.j2
dest: /etc/systemd/system/prometheus-node-exporter.service
owner: root
group: root
mode: 0600
- name: 'node exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-node-exporter.service
- include_tasks: _common.yml
tags: ['prometheus_node']

View File

@ -1,26 +1,6 @@
---
- name: 'opcache exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/MyOnlineStore/opcache-exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
args:
warn: false
register: prometheus_opcache_exporter_latest_version
run_once: true
- name: 'opcache exporter | download'
get_url:
url: https://github.com/MyOnlineStore/opcache-exporter/releases/download/v{{ prometheus_opcache_exporter_version|default(prometheus_opcache_exporter_latest_version.stdout) }}/opcache_exporter-{{ prometheus_opcache_exporter_version|default(prometheus_opcache_exporter_latest_version.stdout) }}-linux-amd64
dest: /tmp
- name: 'opcache exporter | move to /usr/local/bin'
copy:
src: /tmp/opcache_exporter-{{ prometheus_opcache_exporter_version|default(prometheus_opcache_exporter_latest_version.stdout) }}-linux-amd64
dest: /usr/local/bin/prometheus-opcache-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | opcache exporter | restart service'
- include_tasks: _common.yml
tags: ['prometheus_opcache']
- name: 'opcache exporter | configuration'
template:
@ -32,17 +12,3 @@
register: prometheus_opcache_exporter_configuration
notify:
- 'prometheus | opcache exporter | restart service'
- name: 'opcache exporter | install unit file to systemd'
template:
src: systemd/prometheus-opcache-exporter.service.j2
dest: /etc/systemd/system/prometheus-opcache-exporter.service
owner: root
group: root
mode: 0600
- name: 'opcache exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-opcache-exporter.service

View File

@ -1,32 +1,6 @@
---
- name: 'phpfpm exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/Lusitaniae/phpfpm_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
args:
warn: false
register: prometheus_phpfpm_exporter_latest_version
run_once: true
- name: 'phpfpm exporter | download'
get_url:
url: https://github.com/Lusitaniae/phpfpm_exporter/releases/download/v{{ prometheus_phpfpm_exporter_version|default(prometheus_phpfpm_exporter_latest_version.stdout) }}/phpfpm_exporter-{{ prometheus_phpfpm_exporter_version|default(prometheus_phpfpm_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'phpfpm exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/phpfpm_exporter-{{ prometheus_phpfpm_exporter_version|default(prometheus_phpfpm_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'phpfpm exporter | move to /usr/local/bin'
copy:
src: /tmp/phpfpm_exporter-{{ prometheus_phpfpm_exporter_version|default(prometheus_phpfpm_exporter_latest_version.stdout) }}.linux-amd64/phpfpm_exporter
dest: /usr/local/bin/prometheus-phpfpm-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'phpfpm exporter | restart service'
- include_tasks: _common.yml
tags: ['prometheus_phpfpm']
- name: 'phpfpm exporter | install startup script'
template:
@ -37,17 +11,3 @@
mode: 0600
notify:
- 'prometheus | phpfpm exporter | restart service'
- name: 'phpfpm exporter | install unit file to systemd'
template:
src: systemd/prometheus-phpfpm-exporter.service.j2
dest: /etc/systemd/system/prometheus-phpfpm-exporter.service
owner: root
group: root
mode: 0600
- name: 'phpfpm exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-phpfpm-exporter.service

View File

@ -1,32 +1,6 @@
---
- name: '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//"
args:
warn: false
register: prometheus_postgres_exporter_latest_version
run_once: true
- name: 'postgres exporter | download'
get_url:
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
- name: 'postgres exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/postgres_exporter-{{ prometheus_postgres_exporter_version|default(prometheus_postgres_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'postgres exporter | move to /usr/local/bin'
copy:
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
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | postgres exporter | restart service'
- include_tasks: _common.yml
tags: ['prometheus_postgres']
- name: 'postgres exporter | configuration'
template:
@ -38,18 +12,3 @@
register: prometheus_postgres_exporter_configuration
notify:
- 'prometheus | postgres exporter | restart service'
- name: 'postgres exporter | install unit file to systemd'
template:
src: systemd/prometheus-postgres-exporter.service.j2
dest: /etc/systemd/system/prometheus-postgres-exporter.service
owner: root
group: root
mode: 0600
- name: 'postgres exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
state: started
name: prometheus-postgres-exporter.service

View File

@ -1,30 +1,6 @@
---
- name: 'redis exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/oliver006/redis_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
args:
warn: false
register: prometheus_redis_exporter_latest_version
run_once: true
- name: 'redis exporter | download'
get_url:
url: https://github.com/oliver006/redis_exporter/releases/download/v{{ prometheus_redis_exporter_version|default(prometheus_redis_exporter_latest_version.stdout) }}/redis_exporter-v{{ prometheus_redis_exporter_version|default(prometheus_redis_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'redis exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/redis_exporter-v{{ prometheus_redis_exporter_version|default(prometheus_redis_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'redis exporter | move to /usr/local/bin'
copy:
src: /tmp/redis_exporter-v{{ prometheus_redis_exporter_version|default(prometheus_redis_exporter_latest_version.stdout) }}.linux-amd64/redis_exporter
dest: /usr/local/bin/prometheus-redis-exporter
remote_src: yes
owner: root
group: root
mode: 0755
- include_tasks: _common.yml
tags: ['prometheus_redis']
- name: 'redis exporter | configuration'
template:
@ -36,17 +12,3 @@
register: prometheus_redis_exporter_configuration
notify:
- 'prometheus | redis exporter | restart service'
- name: 'redis exporter | install unit file to systemd'
template:
src: systemd/prometheus-redis-exporter.service.j2
dest: /etc/systemd/system/prometheus-redis-exporter.service
owner: root
group: root
mode: 0600
- name: 'redis exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-redis-exporter.service

View File

@ -1,43 +1,3 @@
---
- name: 'varnish exporter | get latest release from GitHub'
shell: curl --silent "https://api.github.com/repos/jonnenauha/prometheus_varnish_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
args:
warn: false
register: prometheus_varnish_exporter_latest_version
run_once: true
- name: 'varnish exporter | download'
get_url:
url: https://github.com/jonnenauha/prometheus_varnish_exporter/releases/download/{{ prometheus_varnish_exporter_version|default(prometheus_varnish_exporter_latest_version.stdout) }}/prometheus_varnish_exporter-{{ prometheus_varnish_exporter_version|default(prometheus_varnish_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'varnish exporter | unarchive'
unarchive:
remote_src: yes
src: /tmp/prometheus_varnish_exporter-{{ prometheus_varnish_exporter_version|default(prometheus_varnish_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
dest: /tmp
- name: 'varnish exporter | move to /usr/local/bin'
copy:
src: /tmp/prometheus_varnish_exporter-{{ prometheus_varnish_exporter_version|default(prometheus_varnish_exporter_latest_version.stdout) }}.linux-amd64/prometheus_varnish_exporter
dest: /usr/local/bin/prometheus-varnish-exporter
remote_src: yes
owner: root
group: root
mode: 0755
notify:
- 'prometheus | varnish exporter | restart service'
- name: 'varnish exporter | install unit file to systemd'
template:
src: systemd/prometheus-varnish-exporter.service.j2
dest: /etc/systemd/system/prometheus-varnish-exporter.service
owner: root
group: root
mode: 0600
- name: 'varnish exporter | configure systemd to use service'
systemd:
daemon_reload: yes
enabled: yes
name: prometheus-varnish-exporter.service
- include_tasks: _common.yml
tags: ['prometheus_varnish']

View File

@ -14,7 +14,7 @@
## include exporter install
- name: 'exporters install'
vars:
service: "{{ item }}"
exporter: "{{ item }}"
include_tasks: "exporter/{{ item }}.yml"
tags:
- prometheus_node_exporter

View File

@ -62,7 +62,7 @@
log_options:
tag: docker_prometheus
restart_policy: 'unless-stopped'
pull: '{{ awh_services_docker_pull }}'
pull: '{{ prometheus_docker_pull }}'
etc_hosts: '{{ prometheus_nodes_ip }}'
tags:
- prometheus