From 758377e89230bc3e4e16f76ee61b998470ca4e72 Mon Sep 17 00:00:00 2001 From: Marcus Klein Date: Tue, 26 Nov 2024 11:27:43 +0100 Subject: [PATCH] Use variables from ansible_facts in prometheus role to allow ANSIBLE_INJECT_FACT_VARS to become false Signed-off-by: Marcus Klein --- roles/prometheus/defaults/main.yml | 4 ++-- roles/prometheus/meta/argument_specs.yml | 4 ++-- roles/prometheus/tasks/main.yml | 2 +- roles/prometheus/templates/prometheus.service.j2 | 2 +- roles/prometheus/vars/main.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/roles/prometheus/defaults/main.yml b/roles/prometheus/defaults/main.yml index e7d45ae76..71c3e7abb 100644 --- a/roles/prometheus/defaults/main.yml +++ b/roles/prometheus/defaults/main.yml @@ -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 @@ -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 }}" diff --git a/roles/prometheus/meta/argument_specs.yml b/roles/prometheus/meta/argument_specs.yml index e9522e59e..790bc3acc 100644 --- a/roles/prometheus/meta/argument_specs.yml +++ b/roles/prometheus/meta/argument_specs.yml @@ -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" @@ -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 }} diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml index bfe59310c..ead587c3b 100644 --- a/roles/prometheus/tasks/main.yml +++ b/roles/prometheus/tasks/main.yml @@ -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 diff --git a/roles/prometheus/templates/prometheus.service.j2 b/roles/prometheus/templates/prometheus.service.j2 index 226c84389..ac113dbe8 100644 --- a/roles/prometheus/templates/prometheus.service.j2 +++ b/roles/prometheus/templates/prometheus.service.j2 @@ -8,7 +8,7 @@ After=local-fs.target [Service] Type=simple -Environment="GOMAXPROCS={{ ansible_processor_vcpus|default(ansible_processor_count) }}" +Environment="GOMAXPROCS={{ ansible_facts['processor_vcpus']|default(ansible_facts['processor_count']) }}" User={{ prometheus_system_user }} Group={{ prometheus_system_group }} ExecReload=/bin/kill -HUP $MAINPID diff --git a/roles/prometheus/vars/main.yml b/roles/prometheus/vars/main.yml index 8ae4feec0..f3a0d75e3 100644 --- a/roles/prometheus/vars/main.yml +++ b/roles/prometheus/vars/main.yml @@ -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 {} }}"