I compared the source codes between 2.3 and 2.4, it seems to me that the
check at
https://github.com/ansible/ansible/blob/stable-2.3/lib/ansible/module_utils/facts.py#L729-L731
is not present something like here
https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/distribution.py#L171
and since no "parse_distribution_file_Archlinux" method is present, it goes
all the way down to "parse_distribution_file_NA" which just plain reads
/etc/os-release.
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?
Le lundi 24 juillet 2017 16:28:00 UTC+2, mdl a écrit :
>
> I saw this <https://github.com/ansible/ansible/pull/15675> 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'.
>
> El lunes, 24 de julio de 2017, 11:07:14 (UTC-3), Mathias Ettinger escribió:
>>
>> Got the same output using ansible 2.4:
>> "ansible_distribution": "Arch Linux",
>> "ansible_distribution_file_parsed": true,
>> "ansible_distribution_file_path": "/etc/os-release",
>> "ansible_distribution_file_variety": "NA",
>> "ansible_distribution_major_version": "NA",
>> "ansible_distribution_release": "NA",
>> "ansible_distribution_version": "NA",
>>
>> the "ansible_distribution_file_path" is new from 2.3 and may be the
>> source of the infos instead of hardcoded ones, hence "Arch Linux"
>>
>>
>>
>> Le lundi 24 juillet 2017 15:37:34 UTC+2, mdl a écrit :
>>>
>>> Thank you so much for your reply Mathias.
>>>
>>> Version:
>>> me@host ~> ansible --version
>>> 2
>>> ansible 2.4.0
>>> config file = /etc/ansible/ansible.cfg
>>> configured module search path = [u'/home/me/.ansible/plugins/modules',
>>> u'/usr/share/ansible/plugins/modules']
>>> ansible python module location = /usr/lib/python2.7/site-packages/
>>> ansible
>>> executable location = /usr/bin/ansible
>>> python version = 2.7.13 (default, Feb 11 2017, 12:22:40) [GCC 6.3.1
>>> 20170109]
>>>
>>> I just tried your example playbook in my computer and got:
>>> me@host ~/Ansible> cat /etc/os-release
>>> NAME="Arch Linux"
>>> PRETTY_NAME="Arch Linux"
>>> ID=arch
>>> ID_LIKE=archlinux
>>> ANSI_COLOR="0;36"
>>> HOME_URL="https://www.archlinux.org/"
>>> SUPPORT_URL="https://bbs.archlinux.org/"
>>> BUG_REPORT_URL="https://bugs.archlinux.org/"
>>>
>>> me@host ~/Ansible> ansible-playbook arch-test.yml | grep ansible_os
>>> "ansible_os_family": "Arch Linux",
>>> "ansible_os_family": "Arch Linux",
>>> "ansible_os_family": "Arch Linux",
>>> "ansible_os_family": "Arch Linux",
>>>
>>> Is version 2.4.0 to blame here?
>>>
>>> El lunes, 24 de julio de 2017, 10:18:13 (UTC-3), Mathias Ettinger
>>> escribió:
>>>>
>>>> Using ansible 2.3.1.0 and the following playbook:
>>>>
>>>> - hosts: localhost
>>>> tasks:
>>>> - debug: msg={{ vars }}
>>>>
>>>> I get, amongst others: "ansible_os_family": "Archlinux", and
>>>> "ansible_distribution": "Archlinux",
>>>>
>>>> What version are you using?
>>>>
>>>>
>>>> Le vendredi 21 juillet 2017 18:32:16 UTC+2, mdl a écrit :
>>>>>
>>>>> 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
>>>>> <https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/distribution.py>)
>>>>>
>>>>> 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.
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1d2a2890-2141-4514-a088-aaac97ef26fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.