Skip to content

Commit

Permalink
Use variables from ansible_facts in prometheus role
Browse files Browse the repository at this point in the history
to allow ANSIBLE_INJECT_FACT_VARS to become false
  • Loading branch information
kleini committed Nov 26, 2024
1 parent 7af35d5 commit 4f11b87
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions roles/prometheus/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
prometheus_version: 3.0.0
prometheus_binary_url: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/\
prometheus-{{ prometheus_version }}.{{ ansible_system | lower }}-{{ _prometheus_go_ansible_arch }}.tar.gz"
prometheus-{{ prometheus_version }}.{{ ansible_facts['system'] | lower }}-{{ _prometheus_go_ansible_arch }}.tar.gz"
prometheus_checksums_url: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/sha256sums.txt"

prometheus_binary_install_dir: /usr/local/bin
Expand Down Expand Up @@ -237,4 +237,4 @@ prometheus_system_user: "{{ prometheus_system_group }}"
prometheus_stop_timeout: '600s'

# Local path to stash the archive and its extraction
prometheus_local_cache_path: "/tmp/prometheus-{{ ansible_system | lower }}-{{ _prometheus_go_ansible_arch }}/{{ prometheus_version }}"
prometheus_local_cache_path: "/tmp/prometheus-{{ ansible_facts['system'] | lower }}-{{ _prometheus_go_ansible_arch }}/{{ prometheus_version }}"
4 changes: 2 additions & 2 deletions roles/prometheus/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ argument_specs:
default: "3.0.0"
prometheus_binary_url:
description: "URL of the prometheus binaries .tar.gz file"
default: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.{{ ansible_system | lower }}-{{ _prometheus_go_ansible_arch }}.tar.gz"
default: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.{{ ansible_facts['system'] | lower }}-{{ _prometheus_go_ansible_arch }}.tar.gz"
prometheus_checksums_url:
description: URL of the prometheus checksums file
default: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/sha256sums.txt"
Expand Down Expand Up @@ -173,4 +173,4 @@ argument_specs:
default: "600s"
prometheus_local_cache_path:
description: Local path to stash the archive and its extraction
default: /tmp/prometheus-{{ ansible_system | lower }}-{{ _prometheus_go_ansible_arch }}/{{ prometheus_version }}
default: /tmp/prometheus-{{ ansible_facts['system'] | lower }}-{{ _prometheus_go_ansible_arch }}/{{ prometheus_version }}
2 changes: 1 addition & 1 deletion roles/prometheus/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
tasks_from: selinux.yml
vars:
_common_selinux_port: "{{ prometheus_web_listen_address | urlsplit('port') }}"
when: ansible_selinux.status == "enabled"
when: ansible_facts['selinux'].status == "enabled"
tags:
- prometheus_configure

Expand Down
2 changes: 1 addition & 1 deletion roles/prometheus/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ _prometheus_go_ansible_arch: "{{ {'i386': '386',
'x86_64': 'amd64',
'aarch64': 'arm64',
'armv7l': 'armv7',
'armv6l': 'armv6'}.get(ansible_architecture, ansible_architecture) }}"
'armv6l': 'armv6'}.get(ansible_facts['architecture'], ansible_facts['architecture']) }}"

_prometheus_repo: "prometheus/prometheus"
_github_api_headers: "{{ {'GITHUB_TOKEN': lookup('ansible.builtin.env', 'GITHUB_TOKEN')} if (lookup('ansible.builtin.env', 'GITHUB_TOKEN')) else {} }}"
Expand Down

0 comments on commit 4f11b87

Please sign in to comment.