mirror of
https://github.com/mdlayher/homelab.git
synced 2024-12-14 11:47:32 +00:00
prometheus: only install different version, unless forced
This commit is contained in:
parent
446cce3960
commit
d8a0df811f
2 changed files with 34 additions and 2 deletions
|
@ -1,7 +1,21 @@
|
||||||
---
|
---
|
||||||
|
- name: check if installing a different version of prometheus
|
||||||
|
tags:
|
||||||
|
- prometheus
|
||||||
|
shell: "cat {{ prometheus_config }}/.sha256"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: checksum
|
||||||
|
|
||||||
|
- name: determine if prometheus {{ prometheus_version}} should be installed
|
||||||
|
tags:
|
||||||
|
- prometheus
|
||||||
|
set_fact:
|
||||||
|
prometheus_install: (checksum.stdout.find(prometheus_sha256) == -1) or (prometheus_force is defined)
|
||||||
|
|
||||||
- name: download and checksum prometheus {{ prometheus_version }} tarball
|
- name: download and checksum prometheus {{ prometheus_version }} tarball
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
when: prometheus_install
|
||||||
get_url:
|
get_url:
|
||||||
url: "{{ prometheus_url }}"
|
url: "{{ prometheus_url }}"
|
||||||
dest: "{{ prometheus_tgz }}"
|
dest: "{{ prometheus_tgz }}"
|
||||||
|
@ -10,6 +24,7 @@
|
||||||
- name: unpack prometheus tarball
|
- name: unpack prometheus tarball
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
when: prometheus_install
|
||||||
unarchive:
|
unarchive:
|
||||||
src: "{{ prometheus_tgz }}"
|
src: "{{ prometheus_tgz }}"
|
||||||
dest: "/tmp/"
|
dest: "/tmp/"
|
||||||
|
@ -18,6 +33,7 @@
|
||||||
- name: create prometheus user
|
- name: create prometheus user
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
when: prometheus_install
|
||||||
user:
|
user:
|
||||||
name: prometheus
|
name: prometheus
|
||||||
shell: "/bin/false"
|
shell: "/bin/false"
|
||||||
|
@ -28,12 +44,12 @@
|
||||||
- prometheus
|
- prometheus
|
||||||
stat:
|
stat:
|
||||||
path: "/etc/systemd/system/prometheus.service"
|
path: "/etc/systemd/system/prometheus.service"
|
||||||
register: checked
|
register: svccheck
|
||||||
|
|
||||||
- name: stop prometheus service if it exists
|
- name: stop prometheus service if it exists
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
when: checked.stat.exists
|
when: svccheck.stat.exists
|
||||||
service:
|
service:
|
||||||
name: prometheus
|
name: prometheus
|
||||||
state: stopped
|
state: stopped
|
||||||
|
@ -41,6 +57,7 @@
|
||||||
- name: copy prometheus binaries to /usr/local/bin
|
- name: copy prometheus binaries to /usr/local/bin
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
when: prometheus_install
|
||||||
command: "cp {{ prometheus_tmp }}/{{ item }} /usr/local/bin/"
|
command: "cp {{ prometheus_tmp }}/{{ item }} /usr/local/bin/"
|
||||||
with_items:
|
with_items:
|
||||||
- "prometheus"
|
- "prometheus"
|
||||||
|
@ -49,6 +66,7 @@
|
||||||
- name: set permissions on prometheus binaries
|
- name: set permissions on prometheus binaries
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
when: prometheus_install
|
||||||
file:
|
file:
|
||||||
path: "/usr/local/bin/{{ item }}"
|
path: "/usr/local/bin/{{ item }}"
|
||||||
owner: prometheus
|
owner: prometheus
|
||||||
|
@ -61,6 +79,7 @@
|
||||||
- name: create prometheus config directory
|
- name: create prometheus config directory
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
when: prometheus_install
|
||||||
file:
|
file:
|
||||||
path: "{{ prometheus_config }}"
|
path: "{{ prometheus_config }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
@ -86,6 +105,7 @@
|
||||||
- name: create prometheus data directory
|
- name: create prometheus data directory
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
when: prometheus_install
|
||||||
file:
|
file:
|
||||||
path: "{{ prometheus_data }}"
|
path: "{{ prometheus_data }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
@ -116,9 +136,18 @@
|
||||||
- name: remove temporary prometheus files
|
- name: remove temporary prometheus files
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
when: prometheus_install
|
||||||
file:
|
file:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ prometheus_tmp }}"
|
- "{{ prometheus_tmp }}"
|
||||||
- "{{ prometheus_tgz }}"
|
- "{{ prometheus_tgz }}"
|
||||||
|
|
||||||
|
- name: create checksum file for prometheus {{ prometheus_version }}
|
||||||
|
tags:
|
||||||
|
- prometheus
|
||||||
|
when: prometheus_install
|
||||||
|
template:
|
||||||
|
src: sha256.j2
|
||||||
|
dest: "{{ prometheus_config }}/.sha256"
|
3
roles/prometheus/templates/sha256.j2
Normal file
3
roles/prometheus/templates/sha256.j2
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
# Remove this file to force ansible to reinstall prometheus {{ prometheus_version }}.
|
||||||
|
{{ prometheus_sha256 }}
|
Loading…
Reference in a new issue