feat: add custom version fact
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
18a50ea2ac
commit
988de7fff3
@ -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
|
||||
|
@ -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
|
||||
|
4
templates/etc/ansible/facts.d/prometheus.fact.j2
Normal file
4
templates/etc/ansible/facts.d/prometheus.fact.j2
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"comment" : "{{ ansible_managed }}",
|
||||
"version" : "{{ prometheus_version }}"
|
||||
}
|
Loading…
Reference in New Issue
Block a user