Skip to content

Commit

Permalink
Use variables from ansible_facts in mysqld_exporter role
Browse files Browse the repository at this point in the history
to allow ANSIBLE_INJECT_FACT_VARS to become false

Signed-off-by: Marcus Klein <[email protected]>
  • Loading branch information
kleini committed Nov 26, 2024
1 parent 4367e25 commit 7af35d5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions roles/mysqld_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
mysqld_exporter_version: 0.16.0
mysqld_exporter_binary_url: "https://github.com/{{ _mysqld_exporter_repo }}/releases/download/v{{ mysqld_exporter_version }}/\
mysqld_exporter-{{ mysqld_exporter_version }}.{{ ansible_system | lower }}-{{ _mysqld_exporter_go_ansible_arch }}.tar.gz"
mysqld_exporter-{{ mysqld_exporter_version }}.{{ ansible_facts['system'] | lower }}-{{ _mysqld_exporter_go_ansible_arch }}.tar.gz"
mysqld_exporter_checksums_url: "https://github.com/{{ _mysqld_exporter_repo }}/releases/download/v{{ mysqld_exporter_version }}/sha256sums.txt"

mysqld_exporter_web_listen_address: "0.0.0.0:9104"
Expand Down Expand Up @@ -34,4 +34,4 @@ mysqld_exporter_system_group: "mysqld-exp"
mysqld_exporter_system_user: "{{ mysqld_exporter_system_group }}"

# Local path to stash the archive and its extraction
mysqld_exporter_local_cache_path: "/tmp/mysqld_exporter-{{ ansible_system | lower }}-{{ _mysqld_exporter_go_ansible_arch }}/{{ mysqld_exporter_version }}"
mysqld_exporter_local_cache_path: "/tmp/mysqld_exporter-{{ ansible_facts['system'] | lower }}-{{ _mysqld_exporter_go_ansible_arch }}/{{ mysqld_exporter_version }}"
4 changes: 2 additions & 2 deletions roles/mysqld_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ argument_specs:
default: "0.16.0"
mysqld_exporter_binary_url:
description: "URL of the mysqld_exporter binaries .tar.gz file"
default: "https://github.com/{{ _mysqld_exporter_repo }}/releases/download/v{{ mysqld_exporter_version }}/mysqld_exporter-{{ mysqld_exporter_version }}.{{ ansible_system | lower }}-{{ _mysqld_exporter_go_ansible_arch }}.tar.gz"
default: "https://github.com/{{ _mysqld_exporter_repo }}/releases/download/v{{ mysqld_exporter_version }}/mysqld_exporter-{{ mysqld_exporter_version }}.{{ ansible_facts['system'] | lower }}-{{ _mysqld_exporter_go_ansible_arch }}.tar.gz"
mysqld_exporter_checksums_url:
description: "URL of the mysqld_exporter checksums file"
default: "https://github.com/{{ _mysqld_exporter_repo }}/releases/download/v{{ mysqld_exporter_version }}/sha256sums.txt"
Expand Down Expand Up @@ -84,4 +84,4 @@ argument_specs:
default: "mysqld-exp"
mysqld_exporter_local_cache_path:
description: "Local path to stash the archive and its extraction"
default: "/tmp/mysqld_exporter-{{ ansible_system | lower }}-{{ _mysqld_exporter_go_ansible_arch }}/{{ mysqld_exporter_version }}"
default: "/tmp/mysqld_exporter-{{ ansible_facts['system'] | lower }}-{{ _mysqld_exporter_go_ansible_arch }}/{{ mysqld_exporter_version }}"
2 changes: 1 addition & 1 deletion roles/mysqld_exporter/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: "{{ mysqld_exporter_web_listen_address | urlsplit('port') }}"
when: ansible_selinux.status == "enabled"
when: ansible_facts['selinux'].status == "enabled"
tags:
- mysqld_exporter_configure

Expand Down
2 changes: 1 addition & 1 deletion roles/mysqld_exporter/templates/mysqld_exporter.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RestartSec=1
StartLimitInterval=0

{% set protect_home = 'yes' %}
{% for m in ansible_mounts if m.mount.startswith('/home') %}
{% for m in ansible_facts['mounts'] if m.mount.startswith('/home') %}
{% set protect_home = 'read-only' %}
{% endfor %}
ProtectHome={{ protect_home }}
Expand Down
2 changes: 1 addition & 1 deletion roles/mysqld_exporter/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ _mysqld_exporter_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']) }}"
_mysqld_exporter_repo: "prometheus/mysqld_exporter"
_github_api_headers: "{{ {'GITHUB_TOKEN': lookup('ansible.builtin.env', 'GITHUB_TOKEN')} if (lookup('ansible.builtin.env', 'GITHUB_TOKEN')) else {} }}"
_mysqld_exporter_binaries: ['mysqld_exporter']

0 comments on commit 7af35d5

Please sign in to comment.