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

Separate downloading and unpacking prometheus archive #102

Merged
merged 3 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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