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:
|
- block:
|
||||||
- name: Create group '{{ prometheus_group }}'
|
- name: Create group '{{ prometheus_group }}'
|
||||||
group:
|
group:
|
||||||
@ -19,5 +26,11 @@
|
|||||||
state: present
|
state: present
|
||||||
loop:
|
loop:
|
||||||
- "{{ prometheus_packages }}"
|
- "{{ prometheus_packages }}"
|
||||||
|
|
||||||
|
- name: Setup local facts
|
||||||
|
file:
|
||||||
|
path: /etc/ansible/facts.d
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
become: True
|
become: True
|
||||||
become_user: root
|
become_user: root
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
notify: __prometheus_restart
|
notify: __prometheus_restart
|
||||||
become: True
|
become: True
|
||||||
become_user: "{{ prometheus_user }}"
|
become_user: "{{ prometheus_user }}"
|
||||||
|
when: prometheus_version is version(prometheus_current_version, ">") or prometheus_current_version is version('0.0.0', "=")
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Copy prometheus config file
|
- name: Copy prometheus config file
|
||||||
@ -111,5 +112,14 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
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: True
|
||||||
become_user: root
|
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