Skip to content

task: Remove host dependant variable from task name#15

Merged
exploide merged 1 commit intoexploide:mainfrom
felinira:wip/fix-hostvar-in-name
Jan 10, 2026
Merged

task: Remove host dependant variable from task name#15
exploide merged 1 commit intoexploide:mainfrom
felinira:wip/fix-hostvar-in-name

Conversation

@felinira
Copy link
Copy Markdown
Contributor

@felinira felinira commented Jan 9, 2026

The content of dnf_automatic_systemd_timer and dnf_automatic_package_name is dependant on the specific version of dnf installed on the host. But ansible only renders the task name globally (once) per task by targeting a host (seemingly at random?). The content of the names can be surprising in multi-os environments, and even lead to errors.

When running this role like this:

- name: Automatic upgrades
  hosts: all
  roles:
    - role: exploide.dnf-automatic
      when: ansible_facts['os_family'] == 'RedHat'

and targeting no RedHat based hosts (such as via -l) this leads to template errors:

[WARNING]: Encountered 1 template error.
error 1 - 'dnf_automatic_systemd_timer' is undefined
Origin: /home/fina/.ansible/roles/exploide.dnf-automatic/tasks/main.yml:68:9

66       notify: Reload systemd
67
68 - name: "Check status of {{ dnf_automatic_systemd_timer }}"
           ^ column 9

because ansible will still try to render each task in the role even though it is displayed as disabled for every host.

Additionally when running this role on dnf4 and dnf5 mixed environments the name is just random.

@felinira felinira force-pushed the wip/fix-hostvar-in-name branch from 5117b5e to c26fb9f Compare January 9, 2026 17:29
@exploide exploide merged commit 7bda4db into exploide:main Jan 10, 2026
1 check passed
@exploide
Copy link
Copy Markdown
Owner

Ah, good to know. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants