From b63c19125eae73599dcacfe1be0563888f236d4c Mon Sep 17 00:00:00 2001 From: Will Buckner <1458615+willbuckner@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:25:43 -0600 Subject: [PATCH] fix(prometheus): use ansible_facts for fqdn Signed-off-by: Will Buckner <1458615+willbuckner@users.noreply.github.com> --- roles/prometheus/defaults/main.yml | 4 ++-- roles/prometheus/meta/argument_specs.yml | 4 ++-- roles/prometheus/molecule/alternative/molecule.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/roles/prometheus/defaults/main.yml b/roles/prometheus/defaults/main.yml index 04c2f2be2..a1f5d971e 100644 --- a/roles/prometheus/defaults/main.yml +++ b/roles/prometheus/defaults/main.yml @@ -66,7 +66,7 @@ prometheus_remote_read: [] # password: FOO prometheus_external_labels: - environment: "{{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }}" + environment: "{{ ansible_facts['fqdn'] | default(ansible_host) | default(inventory_hostname) }}" prometheus_targets: {} # node: @@ -80,7 +80,7 @@ prometheus_scrape_configs: metrics_path: "{{ prometheus_metrics_path }}" static_configs: - targets: - - "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090" + - "{{ ansible_facts['fqdn'] | default(ansible_host) | default('localhost') }}:9090" - job_name: "node" file_sd_configs: - files: diff --git a/roles/prometheus/meta/argument_specs.yml b/roles/prometheus/meta/argument_specs.yml index 3b168ece4..6ec43e83e 100644 --- a/roles/prometheus/meta/argument_specs.yml +++ b/roles/prometheus/meta/argument_specs.yml @@ -100,7 +100,7 @@ argument_specs: description: "Provide map of additional labels which will be added to any time series or alerts when communicating with external systems" type: "dict" default: - environment: "{{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }}" + environment: "{{ ansible_facts['fqdn'] | default(ansible_host) | default(inventory_hostname) }}" prometheus_targets: description: - "Targets which will be scraped." @@ -115,7 +115,7 @@ argument_specs: metrics_path: "{{ prometheus_metrics_path }}" static_configs: - targets: - - "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090" + - "{{ ansible_facts['fqdn'] | default(ansible_host) | default('localhost') }}:9090" - job_name: "node" file_sd_configs: - files: diff --git a/roles/prometheus/molecule/alternative/molecule.yml b/roles/prometheus/molecule/alternative/molecule.yml index dc9d00e88..82b96020c 100644 --- a/roles/prometheus/molecule/alternative/molecule.yml +++ b/roles/prometheus/molecule/alternative/molecule.yml @@ -63,7 +63,7 @@ provisioner: metrics_path: "{{ prometheus_metrics_path }}" static_configs: - targets: - - "{{ ansible_fqdn | default(ansible_host) | default('localhost')\ + - "{{ ansible_facts['fqdn'] | default(ansible_host) | default('localhost')\ \ }}:9090" - job_name: "node" file_sd_configs: