I’m testing Ansible roles with Archlinux and one of them uses ansible_os_family to include variables or tasks. So I have:
`
name: include OS vars
include_vars: “{{ ansible_os_family }}.yml”
when: ansible_os_family == ‘Archlinux’
`
Problem is that ansible_os_family gets ‘Arch Linux’ as value, so ansible looks for ‘Arch Linux.yml’ but filename is actually ‘Archlinux.yml’, just capital A and no spaces. I know this is not a fancy bug or anything, I’ve been looking at ansible code and GitHub issues but only found OS_FAMILY_MAP (Code here) and Arch seems to be defined as ‘Archlinux’ but never ‘Arch Linux’.
Could anyone guide me because I do not know if something changed with /etc/os-release in Archlinux or maybe a bug needs to be reported to update variables like OS_FAMILY_MAP.
I saw this issue at GitHub where people requested to get Archlinux detection from /etc/os-release. It seems to be related to this. What’s the best way to address this with the Ansible team? It’s not a big issue but having no spaces in distribution or family name is a good practice.
Thanks for your help, it’s nice to know the root of the ‘problem’.
Maybe it’s time to implement such method for custom logic, or stick to the ‘allowempty’ trick.
I also tryed manually applying the fix provided in #15675 and got the desired output:
“ansible_distribution”: “Archlinux”,
“ansible_distribution_file_parsed”: true,
“ansible_distribution_file_path”: “/etc/os-release”,
“ansible_distribution_file_variety”: “Archlinux”,
“ansible_distribution_major_version”: “NA”,
“ansible_distribution_release”: “NA”,
“ansible_distribution_version”: “NA”,
so maybe just update this PR instead (or #22949) to modify the right file?
“systemd is a first class citizen in Arch Linux variants and thus /etc/os-release will always have the right info [1]. We don’t need to rely on /etc/arch-release and allowempty workaround.”
"systemd is a first class citizen in Arch Linux variants and thus /etc/os-release will always have the right info [1]. We don't need to rely on /etc/arch-release and allowempty workaround."
Is that correct?
No, we have encountered systems that did not conform to that
statement. They might be old, but not everyone can update/upgrade at
same pace (even with rolling release distros).
Adrian, I did not understand what you meant for background when it comes to values being different, I’m sorry.
I’m asking now you and Mathias as I’m in the dark here: should I update #22949 with a report of what’s been discussed in this thread or should I rebase following ansible guide? I’m no developer but I understand the changes stated in PR #22949. I really don’t want to screw something up or do something dumb due my lack of experience.