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

Commit

Permalink
split download and unarchive and add checksum validation (#35)
Browse files Browse the repository at this point in the history
* split download and unarchive; add checksum validation

* fix deprecation warning
  • Loading branch information
paulfantom authored May 12, 2018
1 parent 03a4812 commit b75a6eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,27 @@
createhome: false
home: /

- name: Download Node exporter binary to local folder
- name: Download node_exporter binary to local folder
become: false
unarchive:
src: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
get_url:
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
dest: "/tmp"
remote_src: true
creates: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/node_exporter"
checksum: "sha256:{{ node_exporter_checksum }}"
register: _download_binary
until: _download_binary is succeeded
retries: 5
delay: 2
delegate_to: localhost
check_mode: false

- name: Unpack node_exporter binary
become: false
unarchive:
src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
dest: "/tmp"
creates: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/node_exporter"
delegate_to: localhost
check_mode: false

- name: Propagate Node Exporter binaries
copy:
Expand Down
7 changes: 7 additions & 0 deletions tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
msg: "Collector cannot be both disabled and enabled"
when: item in node_exporter_enabled_collectors
with_items: "{{ node_exporter_disabled_collectors }}"

- name: "Get checksum for {{ go_arch_map[ansible_architecture] | default(ansible_architecture) }} architecture"
set_fact:
node_exporter_checksum: "{{ item.split(' ')[0] }}"
with_items:
- "{{ lookup('url', 'https://github.com/prometheus/node_exporter/releases/download/v' + node_exporter_version + '/sha256sums.txt', wantlist=True) | list }}"
when: "('linux-' + (go_arch_map[ansible_architecture] | default(ansible_architecture)) + '.tar.gz') in item"

0 comments on commit b75a6eb

Please sign in to comment.