feat: add custom version fact
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Robert Kaussow 2021-05-29 22:48:56 +02:00
parent 18a50ea2ac
commit 988de7fff3
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
3 changed files with 27 additions and 0 deletions

View File

@ -1,4 +1,11 @@
---
- name: Set current prometheus version
set_fact:
prometheus_current_version: "{{ (ansible_local.prometheus | default (dict(version='0.0.0')))['version'] }}"
- debug:
msg: Current version is '{{ prometheus_current_version }}'
- block:
- name: Create group '{{ prometheus_group }}'
group:
@ -19,5 +26,11 @@
state: present
loop:
- "{{ prometheus_packages }}"
- name: Setup local facts
file:
path: /etc/ansible/facts.d
state: directory
mode: 0755
become: True
become_user: root

View File

@ -35,6 +35,7 @@
notify: __prometheus_restart
become: True
become_user: "{{ prometheus_user }}"
when: prometheus_version is version(prometheus_current_version, ">") or prometheus_current_version is version('0.0.0', "=")
- block:
- name: Copy prometheus config file
@ -111,5 +112,14 @@
daemon_reload: yes
enabled: yes
state: started
- name: Set current version to custom fact
template:
src: etc/ansible/facts.d/prometheus.fact.j2
dest: /etc/ansible/facts.d/prometheus.fact
mode: 0644
owner: root
group: root
when: prometheus_version is version(prometheus_current_version, ">") or prometheus_current_version is version('0.0.0', "=")
become: True
become_user: root

View File

@ -0,0 +1,4 @@
{
"comment" : "{{ ansible_managed }}",
"version" : "{{ prometheus_version }}"
}