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

Commit

Permalink
Merge pull request #102 from cloudalchemy/issue101
Browse files Browse the repository at this point in the history
[patch] Separate downloading and unpacking prometheus archive
  • Loading branch information
paulfantom authored Apr 20, 2018
2 parents e04ff63 + c767976 commit 9204adb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Deploy [Prometheus](https://github.com/prometheus/prometheus) monitoring system

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

## Role Variables

Expand Down
38 changes: 22 additions & 16 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,24 @@

- name: download prometheus binary to local folder
become: no
unarchive:
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"
get_url:
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"
dest: "/tmp"
remote_src: yes
creates: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/prometheus"
register: _download_binary
until: _download_binary is succeeded
register: _download_archive
until: _download_archive is succeeded
retries: 5
delay: 2
# run_once: true
# run_once: true # <-- this cannot be set due to multi-arch support
delegate_to: localhost
check_mode: no

- name: remove prometheus binaries from old location
file:
path: "{{ item }}"
state: absent
with_items:
- /opt/prometheus/prometheus
- /opt/prometheus/promtool
- /opt/prometheus
- name: unpack prometheus binaries
become: no
unarchive:
src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
dest: "/tmp"
creates: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/prometheus"
delegate_to: localhost
check_mode: no

- name: propagate prometheus and promtool binaries
copy:
Expand All @@ -72,6 +69,15 @@
notify:
- restart prometheus

- name: remove prometheus binaries from old location
file:
path: "{{ item }}"
state: absent
with_items:
- /opt/prometheus/prometheus
- /opt/prometheus/promtool
- /opt/prometheus

- name: create systemd service unit
template:
src: prometheus.service.j2
Expand Down

0 comments on commit 9204adb

Please sign in to comment.