Skip to content
This repository was archived by the owner on Mar 6, 2023. It is now read-only.

Commit 9204adb

Browse files
authored
Merge pull request #102 from cloudalchemy/issue101
[patch] Separate downloading and unpacking prometheus archive
2 parents e04ff63 + c767976 commit 9204adb

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Deploy [Prometheus](https://github.com/prometheus/prometheus) monitoring system
1616

1717
- Ansible >= 2.3
1818
- jmespath on deployer machine. If you are using Ansible from a Python virtualenv, install *jmespath* to the same virtualenv via pip.
19+
- gnu-tar on Mac deployer host (`brew install gnu-tar`)
1920

2021
## Role Variables
2122

tasks/install.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,24 @@
3636

3737
- name: download prometheus binary to local folder
3838
become: no
39-
unarchive:
40-
src: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
39+
get_url:
40+
url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
4141
dest: "/tmp"
42-
remote_src: yes
43-
creates: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/prometheus"
44-
register: _download_binary
45-
until: _download_binary is succeeded
42+
register: _download_archive
43+
until: _download_archive is succeeded
4644
retries: 5
4745
delay: 2
48-
# run_once: true
46+
# run_once: true # <-- this cannot be set due to multi-arch support
4947
delegate_to: localhost
50-
check_mode: no
5148

52-
- name: remove prometheus binaries from old location
53-
file:
54-
path: "{{ item }}"
55-
state: absent
56-
with_items:
57-
- /opt/prometheus/prometheus
58-
- /opt/prometheus/promtool
59-
- /opt/prometheus
49+
- name: unpack prometheus binaries
50+
become: no
51+
unarchive:
52+
src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
53+
dest: "/tmp"
54+
creates: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/prometheus"
55+
delegate_to: localhost
56+
check_mode: no
6057

6158
- name: propagate prometheus and promtool binaries
6259
copy:
@@ -72,6 +69,15 @@
7269
notify:
7370
- restart prometheus
7471

72+
- name: remove prometheus binaries from old location
73+
file:
74+
path: "{{ item }}"
75+
state: absent
76+
with_items:
77+
- /opt/prometheus/prometheus
78+
- /opt/prometheus/promtool
79+
- /opt/prometheus
80+
7581
- name: create systemd service unit
7682
template:
7783
src: prometheus.service.j2

0 commit comments

Comments
 (0)