Skip to content

Commit

Permalink
Get checksum for each platform on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
GlauberrBatista committed Nov 22, 2022
1 parent 92103f7 commit 50722b6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 0 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# defaults file for prometheus-postgres

prometheus_postgres_version: 0.9.0
prometheus_postgres_sha256: >-
ff541bd3ee19c0ae003d71424a75edfcc8695e828dd20d5b4555ce433c89d60b

prometheus_postgres_dbname: postgres
prometheus_postgres_data_source_name: "user=postgres dbname=\
Expand Down
28 changes: 23 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,40 @@
- /opt/prometheus/postgres
- /etc/prometheus

- name: prometheus postgres | get checksums
set_fact:
checksum_list: "{{ lookup('url', \
'https://github.com/prometheus-community/postgres_exporter/\
releases/download/v' + prometheus_postgres_version + '/\
sha256sums.txt', wantlist=True) | list }}"
delegate_to: localhost
run_once: true

- name: prometheus postgres | get checksum for {{ go_arch }}
set_fact:
exporter_checksum: "{{ item.split(' ')[0] }}"
with_items: "{{ checksum_list }}"
delegate_to: localhost
when:
- "('linux-' + go_arch + '.tar.gz') in item"

- name: prometheus postgres | download
become: true
get_url:
# note the v0.9.0 in tag but 0.9.0 in the filename
url: "https://github.com/prometheus-community/postgres_exporter/\
releases/download/v{{ prometheus_postgres_version }}/\
postgres_exporter-{{ prometheus_postgres_version }}.linux-amd64.tar.gz"
checksum: sha256:{{ prometheus_postgres_sha256 }}
postgres_exporter-{{ prometheus_postgres_version }}.\
linux-{{ go_arch }}.tar.gz"
checksum: sha256:{{ exporter_checksum }}
dest: "/opt/prometheus/postgres_exporter\
-{{ prometheus_postgres_version }}.linux-amd64.tar.gz"
-{{ prometheus_postgres_version }}.linux-{{ go_arch }}.tar.gz"

- name: prometheus postgres | install postgres-exporter
become: true
unarchive:
src: "/opt/prometheus/postgres_exporter\
-{{ prometheus_postgres_version }}.linux-amd64.tar.gz"
-{{ prometheus_postgres_version }}.linux-{{ go_arch }}.tar.gz"
dest: /opt/prometheus
group: root
owner: root
Expand All @@ -45,7 +63,7 @@
become: true
file:
src: "/opt/prometheus/postgres_exporter\
-{{ prometheus_postgres_version }}.linux-amd64"
-{{ prometheus_postgres_version }}.linux-{{ go_arch }}"
path: /opt/prometheus/postgres_exporter
force: true
state: link
Expand Down

0 comments on commit 50722b6

Please sign in to comment.