refactor: support customizing prometheus url/mirror

Signed-off-by: gardar <gardar@users.noreply.github.com>
This commit is contained in:
gardar 2023-02-22 17:20:00 +00:00
parent 9f4c0243e5
commit e57ae9b9d7
No known key found for this signature in database
GPG key ID: 75FAE37CBA8C13C2
4 changed files with 7 additions and 4 deletions

View file

@ -26,6 +26,8 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults
| `prometheus_skip_install` | false | Prometheus installation tasks gets skipped when set to true. |
| `prometheus_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `prometheus` AND `promtool` binaries are stored on host on which ansible is ran. This overrides `prometheus_version` parameter |
| `prometheus_config_dir` | /etc/prometheus | Path to directory with prometheus configuration |
| `prometheus_binary_url` | `https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz` | URL of the prometheus binaries .tar.gz file |
| `prometheus_checksums_url` | `https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/sha256sums.txt` | URL of the prometheus checksums file |
| `prometheus_db_dir` | /var/lib/prometheus | Path to directory with prometheus database |
| `prometheus_read_only_dirs`| [] | Additional paths that Prometheus is allowed to read (useful for SSL certs outside of the config directory) |
| `prometheus_web_listen_address` | "0.0.0.0:9090" | Address on which prometheus will be listening |

View file

@ -1,6 +1,9 @@
---
prometheus_version: 2.27.0
prometheus_binary_local_dir: ''
prometheus_binary_url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/\
prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
prometheus_checksums_url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/sha256sums.txt"
prometheus_skip_install: false
prometheus_config_dir: /etc/prometheus

View file

@ -43,8 +43,7 @@
- name: Download prometheus binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/\
prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
url: "{{ prometheus_binary_url }}"
dest: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
checksum: "sha256:{{ __prometheus_checksum }}"
mode: 0644

View file

@ -91,8 +91,7 @@
block:
- name: "Get checksum list"
ansible.builtin.set_fact:
__prometheus_checksums: "{{ lookup('url', 'https://github.com/prometheus/prometheus/releases/download/v' + prometheus_version + '/sha256sums.txt',
wantlist=True) | list }}"
__prometheus_checksums: "{{ lookup('url', prometheus_checksums_url, wantlist=True) | list }}"
run_once: true
until: __prometheus_checksums is search('linux-' + go_arch + '.tar.gz')
retries: 10