Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible_distribution for Arch changed in ansible 2.4 #30600

Closed
ykuksenko opened this issue Sep 20, 2017 · 22 comments · Fixed by #30723
Closed

ansible_distribution for Arch changed in ansible 2.4 #30600

ykuksenko opened this issue Sep 20, 2017 · 22 comments · Fixed by #30723
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@ykuksenko
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Facts

ANSIBLE VERSION
ansible 2.4.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/ansible/.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, Jul 21 2017, 03:24:34) [GCC 7.1.1 20170630]
CONFIGURATION
OS / ENVIRONMENT

On Arch controling Arch

SUMMARY

As of Ansible 2.4 (I believe commit 45a9f96) the
ansible_distribution and ansible_os_family facts changed for Arch Linux breaking multiple modules.

STEPS TO REPRODUCE
ansible -m setup archhost -i inventories/production |grep arch -i
EXPECTED RESULTS
"ansible_distribution": "Archlinux",
"ansible_os_family": "Archlinux",
ACTUAL RESULTS

There is now a space and a capital L in the distribution name for Archlinux.

"ansible_distribution": "Arch Linux", 
"ansible_os_family": "Arch Linux",
@ykuksenko ykuksenko changed the title ansible_distribution for Arch ansible_distribution for Arch changed in ansible 2.4 Sep 20, 2017
@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 20, 2017
@alikins
Copy link
Contributor

alikins commented Sep 20, 2017

What do the other distribution facts end up as?

ansible_distribution
ansible_os_family
ansible_distribution_release
ansible_distribution_version
ansible_distribution_file_parsed
ansible_distribution_file_variety
ansible_distribution_file_path
ansible_major_version

(Or a copy of the entire system facts output from 'ansible $THAT_ARCH_HOST -m set' would also be useful).

@alikins alikins added needs_info This issue requires further information. Please answer any outstanding questions. and removed needs_triage Needs a first human triage before being processed. labels Sep 20, 2017
@shakeme
Copy link

shakeme commented Sep 20, 2017

Same problem here:

ansible 2.4.0.0

"ansible_distribution": "Arch Linux",
"ansible_os_family": "Arch Linux",
"ansible_distribution_release": "NA",
"ansible_distribution_version": "NA",
"ansible_distribution_file_parsed": true,
"ansible_distribution_file_variety": "NA",
"ansible_distribution_file_path": "/etc/os-release",
"ansible_distribution_major_version": "NA",

@alikins
Copy link
Contributor

alikins commented Sep 20, 2017

@ykuksenko If you are running ansible from a source checkout, could you also run 'ansible/hacking/tests/gen_distribution_version_testcase.py' on the arch box and include the output?

@alikins
Copy link
Contributor

alikins commented Sep 20, 2017

@shakeme What are the contents of '/etc/os-release' ?

@alikins
Copy link
Contributor

alikins commented Sep 20, 2017

and/or /etc/arch-release?

@shakeme
Copy link

shakeme commented Sep 20, 2017

Content of /etc/os-release is:

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/"

@shakeme
Copy link

shakeme commented Sep 20, 2017

/etc/arch-release is empty.

@ykuksenko
Copy link
Author

Contents of /etc/os-release and the requested variables is the same for me as @shakeme.

This one is the same in checkout and 2.3.2.0:
"ansible_distribution_major_version": "NA",

/tmp/ansible/hacking/tests/gen_distribution_version_testcase.py:

{
    "platform.dist": [
        "",
        "",
        ""
    ],
    "input": {
        "/etc/os-release": "NAME=\"Arch Linux\"\nPRETTY_NAME=\"Arch Linux\"\nID=arch\nID_LIKE=archlinux\nANSI_COLOR=\"0;36\"\nHOME_URL=\"https://www.archlinux.org/\"\nSUPPORT_URL=\"https://bbs.archlinux.org/\"\nBUG_REPORT_URL=\"https://bugs.archlinux.org/\"\n\n"
    },
    "name": "Arch Linux NA",
    "result": {
        "distribution_release": "NA",
        "distribution": "Arch Linux",
        "distribution_major_version": "NA",
        "os_family": "Arch Linux",
        "distribution_version": "NA"
    }
}

@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label Sep 21, 2017
@ykuksenko
Copy link
Author

full dump of facts:
ansible -m setup generic

generic | SUCCESS => {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "192.168.32.99"
        ], 
        "ansible_all_ipv6_addresses": [
            "fe80::5054:99ff:fe99:9999"
        ], 
        "ansible_apparmor": {
            "status": "disabled"
        }, 
        "ansible_architecture": "x86_64", 
        "ansible_bios_date": "04/01/2014", 
        "ansible_bios_version": "1.10.2-20170228_101828-anatol", 
        "ansible_cmdline": {
            "BOOT_IMAGE": "/vmlinuz-linux", 
            "quiet": true, 
            "root": "UUID=fae4485b-dac8-4524-8aec-cbd833ffd8f1", 
            "rw": true
        }, 
        "ansible_date_time": {
            "date": "2017-09-20", 
            "day": "20", 
            "epoch": "1505966277", 
            "hour": "22", 
            "iso8601": "2017-09-21T03:57:57Z", 
            "iso8601_basic": "20170920T225757523898", 
            "iso8601_basic_short": "20170920T225757", 
            "iso8601_micro": "2017-09-21T03:57:57.524014Z", 
            "minute": "57", 
            "month": "09", 
            "second": "57", 
            "time": "22:57:57", 
            "tz": "CDT", 
            "tz_offset": "-0500", 
            "weekday": "Wednesday", 
            "weekday_number": "3", 
            "weeknumber": "38", 
            "year": "2017"
        }, 
        "ansible_default_ipv4": {
            "address": "192.168.32.99", 
            "alias": "ens3", 
            "broadcast": "192.168.32.255", 
            "gateway": "192.168.32.254", 
            "interface": "ens3", 
            "macaddress": "52:54:99:99:99:99", 
            "mtu": 1500, 
            "netmask": "255.255.255.0", 
            "network": "192.168.32.0", 
            "type": "ether"
        }, 
        "ansible_default_ipv6": {}, 
        "ansible_device_links": {
            "ids": {
                "sr0": [
                    "ata-QEMU_DVD-ROM_QM00005"
                ]
            }, 
            "labels": {
                "sr0": [
                    "cidata"
                ]
            }, 
            "masters": {}, 
            "uuids": {
                "sr0": [
                    "2017-09-20-22-56-29-37"
                ], 
                "vda2": [
                    "005a0572-7473-42af-ad50-e1633d2c579f"
                ], 
                "vda4": [
                    "fae4485b-dac8-4524-8aec-cbd833ffd8f1"
                ]
            }
        }, 
        "ansible_devices": {
            "sr0": {
                "holders": [], 
                "host": "SATA controller: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] (rev 02)", 
                "links": {
                    "ids": [
                        "ata-QEMU_DVD-ROM_QM00005"
                    ], 
                    "labels": [
                        "cidata"
                    ], 
                    "masters": [], 
                    "uuids": [
                        "2017-09-20-22-56-29-37"
                    ]
                }, 
                "model": "QEMU DVD-ROM", 
                "partitions": {}, 
                "removable": "1", 
                "rotational": "1", 
                "sas_address": null, 
                "sas_device_handle": null, 
                "scheduler_mode": "cfq", 
                "sectors": "732", 
                "sectorsize": "2048", 
                "size": "1.43 MB", 
                "support_discard": "0", 
                "vendor": "QEMU", 
                "virtual": 1
            }, 
            "vda": {
                "holders": [], 
                "host": "SCSI storage controller: Red Hat, Inc Virtio block device", 
                "links": {
                    "ids": [], 
                    "labels": [], 
                    "masters": [], 
                    "uuids": []
                }, 
                "model": null, 
                "partitions": {
                    "vda1": {
                        "holders": [], 
                        "links": {
                            "ids": [], 
                            "labels": [], 
                            "masters": [], 
                            "uuids": []
                        }, 
                        "sectors": "2048", 
                        "sectorsize": 512, 
                        "size": "1.00 MB", 
                        "start": "2048", 
                        "uuid": null
                    }, 
                    "vda2": {
                        "holders": [], 
                        "links": {
                            "ids": [], 
                            "labels": [], 
                            "masters": [], 
                            "uuids": [
                                "005a0572-7473-42af-ad50-e1633d2c579f"
                            ]
                        }, 
                        "sectors": "524288", 
                        "sectorsize": 512, 
                        "size": "256.00 MB", 
                        "start": "4096", 
                        "uuid": "005a0572-7473-42af-ad50-e1633d2c579f"
                    }, 
                    "vda3": {
                        "holders": [], 
                        "links": {
                            "ids": [], 
                            "labels": [], 
                            "masters": [], 
                            "uuids": []
                        }, 
                        "sectors": "2097152", 
                        "sectorsize": 512, 
                        "size": "1.00 GB", 
                        "start": "528384", 
                        "uuid": null
                    }, 
                    "vda4": {
                        "holders": [], 
                        "links": {
                            "ids": [], 
                            "labels": [], 
                            "masters": [], 
                            "uuids": [
                                "fae4485b-dac8-4524-8aec-cbd833ffd8f1"
                            ]
                        }, 
                        "sectors": "30928863", 
                        "sectorsize": 512, 
                        "size": "14.75 GB", 
                        "start": "2625536", 
                        "uuid": "fae4485b-dac8-4524-8aec-cbd833ffd8f1"
                    }
                }, 
                "removable": "0", 
                "rotational": "1", 
                "sas_address": null, 
                "sas_device_handle": null, 
                "scheduler_mode": "mq-deadline", 
                "sectors": "33554432", 
                "sectorsize": "512", 
                "size": "16.00 GB", 
                "support_discard": "0", 
                "vendor": "0x1af4", 
                "virtual": 1
            }
        }, 
        "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", 
        "ansible_dns": {
            "nameservers": [
                "192.168.32.254"
            ], 
            "search": [
                "l.domain.org", 
                "domain.org"
            ]
        }, 
        "ansible_domain": "t.domain.org", 
        "ansible_effective_group_id": 1336, 
        "ansible_effective_user_id": 1336, 
        "ansible_ens3": {
            "active": true, 
            "device": "ens3", 
            "ipv4": {
                "address": "192.168.32.99", 
                "broadcast": "192.168.32.255", 
                "netmask": "255.255.255.0", 
                "network": "192.168.32.0"
            }, 
            "ipv6": [
                {
                    "address": "fe80::5054:99ff:fe99:9999", 
                    "prefix": "64", 
                    "scope": "link"
                }
            ], 
            "macaddress": "52:54:99:99:99:99", 
            "module": "virtio_net", 
            "mtu": 1500, 
            "pciid": "virtio0", 
            "promisc": false, 
            "speed": -1, 
            "type": "ether"
        }, 
        "ansible_env": {
            "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1336/bus", 
            "HOME": "/home/ansibler", 
            "LOGNAME": "ansibler", 
            "MAIL": "/var/spool/mail/ansibler", 
            "PATH": "/usr/bin:/bin:/usr/sbin:/sbin", 
            "PWD": "/home/ansibler", 
            "SHELL": "/bin/bash", 
            "SHLVL": "2", 
            "SSH_CLIENT": "192.168.0.201 50298 22", 
            "SSH_CONNECTION": "192.168.0.201 50298 192.168.32.99 22", 
            "SSH_TTY": "/dev/pts/0", 
            "TERM": "xterm-256color", 
            "USER": "ansibler", 
            "XDG_RUNTIME_DIR": "/run/user/1336", 
            "XDG_SESSION_ID": "c1", 
            "_": "/usr/bin/python"
        }, 
        "ansible_fips": false, 
        "ansible_form_factor": "Other", 
        "ansible_fqdn": "generic.domain.org", 
        "ansible_hostname": "generic", 
        "ansible_interfaces": [
            "lo", 
            "ens3"
        ], 
        "ansible_is_chroot": true, 
        "ansible_kernel": "4.12.13-1-ARCH", 
        "ansible_lo": {
            "active": true, 
            "device": "lo", 
            "ipv4": {
                "address": "127.0.0.1", 
                "broadcast": "host", 
                "netmask": "255.0.0.0", 
                "network": "127.0.0.0"
            }, 
            "ipv6": [
                {
                    "address": "::1", 
                    "prefix": "128", 
                    "scope": "host"
                }
            ], 
            "mtu": 65536, 
            "promisc": false, 
            "type": "loopback"
        }, 
        "ansible_local": {}, 
        "ansible_lsb": {}, 
        "ansible_machine": "x86_64", 
        "ansible_machine_id": "753f214610b04bfba1778d37a1b3c6c1", 
        "ansible_memfree_mb": 320, 
        "ansible_memory_mb": {
            "nocache": {
                "free": 421, 
                "used": 71
            }, 
            "real": {
                "free": 320, 
                "total": 492, 
                "used": 172
            }, 
            "swap": {
                "cached": 0, 
                "free": 0, 
                "total": 0, 
                "used": 0
            }
        }, 
        "ansible_memtotal_mb": 492, 
        "ansible_mounts": [
            {
                "block_available": 3243785, 
                "block_size": 4096, 
                "block_total": 3866107, 
                "block_used": 622322, 
                "device": "/dev/vda4", 
                "fstype": "btrfs", 
                "inode_available": 0, 
                "inode_total": 0, 
                "inode_used": 0, 
                "mount": "/", 
                "options": "rw,relatime,discard,space_cache,subvolid=5,subvol=/", 
                "size_available": 13286543360, 
                "size_total": 15835574272, 
                "uuid": "fae4485b-dac8-4524-8aec-cbd833ffd8f1"
            }, 
            {
                "block_available": 180063, 
                "block_size": 1024, 
                "block_total": 245671, 
                "block_used": 65608, 
                "device": "/dev/vda2", 
                "fstype": "ext4", 
                "inode_available": 65166, 
                "inode_total": 65536, 
                "inode_used": 370, 
                "mount": "/boot", 
                "options": "rw,relatime,data=ordered", 
                "size_available": 184384512, 
                "size_total": 251567104, 
                "uuid": "005a0572-7473-42af-ad50-e1633d2c579f"
            }
        ], 
        "ansible_nodename": "generic.domain.org", 
        "ansible_os_family": "Arch Linux", 
        "ansible_pkg_mgr": "pacman", 
        "ansible_processor": [
            "0", 
            "GenuineIntel", 
            "Westmere E56xx/L56xx/X56xx (Nehalem-C)"
        ], 
        "ansible_processor_cores": 1, 
        "ansible_processor_count": 1, 
        "ansible_processor_threads_per_core": 1, 
        "ansible_processor_vcpus": 1, 
        "ansible_product_name": "Standard PC (i440FX + PIIX, 1996)", 
        "ansible_product_serial": "NA", 
        "ansible_product_uuid": "NA", 
        "ansible_product_version": "pc-i440fx-2.8", 
        "ansible_python": {
            "executable": "/usr/bin/python", 
            "has_sslcontext": true, 
            "type": "cpython", 
            "version": {
                "major": 3, 
                "micro": 2, 
                "minor": 6, 
                "releaselevel": "final", 
                "serial": 0
            }, 
            "version_info": [
                3, 
                6, 
                2, 
                "final", 
                0
            ]
        }, 
        "ansible_python_version": "3.6.2",
        "ansible_real_group_id": 1336,
        "ansible_real_user_id": 1336,
        "ansible_selinux": false,
        "ansible_selinux_python_present": false,
        "ansible_service_mgr": "systemd",
        "ansible_ssh_host_key_dsa_public": "",
        "ansible_ssh_host_key_ecdsa_public": "",
        "ansible_ssh_host_key_ed25519_public": "",
        "ansible_ssh_host_key_rsa_public": "",
        "ansible_swapfree_mb": 0,
        "ansible_swaptotal_mb": 0,
        "ansible_system": "Linux",
        "ansible_system_capabilities": [
            ""
        ],
        "ansible_system_capabilities_enforced": "True",
        "ansible_system_vendor": "QEMU",
        "ansible_uptime_seconds": 70,
        "ansible_user_dir": "/home/ansible",
        "ansible_user_gecos": "",
        "ansible_user_gid": 1336,
        "ansible_user_id": "ansible",
        "ansible_user_shell": "/bin/bash",
        "ansible_user_uid": 1336,
        "ansible_userspace_architecture": "x86_64",
        "ansible_userspace_bits": "64",
        "ansible_virtualization_role": "guest",
        "ansible_virtualization_type": "kvm",
        "gather_subset": [
            "all"
        ],
        "module_setup": true
    },
    "changed": false,
    "failed": false
}

@alikins
Copy link
Contributor

alikins commented Sep 21, 2017

Wondering if this is dependent on which order the distribution file based code runs, since it seems to be falling back to using /etc/os-release (where 'Arch Linux' comes from) instead of choosing 'ArchLinux' because it found a (possibly empty) /etc/arch-release. If the os-release runs first and finds something, it wouldn't continue, but need to dig into why/if it could be a different order.

@bcoca
Copy link
Member

bcoca commented Sep 21, 2017

arch-release is probably only populated on older Arch machines, we should support both but os-release will be the one most often populated.

@alikins
Copy link
Contributor

alikins commented Sep 21, 2017

@ykuksenko Thanks for the test data.

Running that test data the chosen name ends up being 'Arch Linux'.

@alikins
Copy link
Contributor

alikins commented Sep 21, 2017

Wondering if this is dependent on which order the distribution file based code runs, since it seems to be falling back to using /etc/os-release (where 'Arch Linux' comes from) instead of choosing 'ArchLinux' because it found a (possibly empty) /etc/arch-release. If the os-release runs first and finds something, it wouldn't continue, but need to dig into why/if it could be a different order.

Nope, not that. missing case for breaking on a match with allow_empty, working on pr

@alikins
Copy link
Contributor

alikins commented Sep 21, 2017

@bcoca

arch-release is probably only populated on older Arch machines, we should support both but os-release will be the one most often populated.

Need to add a special case for Arch with no arch-release but with a os-release. Current code will fallback to os-release in that case, but the name in os-release is 'ArchLinux' vs 'Archlinux' that a hit on /etc/arch-release triggers.

@alikins
Copy link
Contributor

alikins commented Sep 22, 2017

@shakeme @ykuksenko pr #30723 has a proposed fix for this if y'all want to test it out.

@shakeme
Copy link

shakeme commented Sep 22, 2017

@alikins It's working but some of the variable from above are vanished. I don't need them, just for information. Thank you.

$ ansible -m setup localhost | grep -E "_os|_distrib"
"ansible_distribution": "Archlinux",
"ansible_distribution_major_version": "NA",
"ansible_distribution_release": "NA",
"ansible_distribution_version": "NA",
"ansible_os_family": "Archlinux",

$ ansible --version
ansible 2.5.0 (pull30723 08cca42) last updated 2017/09/22 22:31:48 (GMT +200)
config file = None
...
python version = 2.7.14 (default, Sep 20 2017, 01:25:59) [GCC 7.2.0]

@ykuksenko
Copy link
Author

Not sure if you want me to confirm or not. I got the same results as @shakeme
ansible -m setup generic | grep -E "_os|_distrib":

        "ansible_distribution": "Archlinux", 
        "ansible_distribution_major_version": "NA", 
        "ansible_distribution_release": "NA", 
        "ansible_distribution_version": "NA", 
        "ansible_os_family": "Archlinux",

ansible --version

ansible 2.5.0 (detached HEAD 08cca42fd4) last updated 2017/09/22 17:07:23 (GMT -500)
  config file = /etc/ansible/ansible.cfg
  ...
  python version = 2.7.13 (default, Jul 21 2017, 03:24:34) [GCC 7.1.1 20170630]

@Asher256
Copy link
Contributor

Asher256 commented Sep 24, 2017

Same issue here. The space added between "Arch" and "Linux" breaks lots of modules.

$ ansible docker_arch -m setup | grep -i "arch"
docker_arch | SUCCESS => {
        "ansible_architecture": "x86_64", 
        "ansible_distribution": "Arch Linux",
        "ansible_kernel": "4.12.13-1-ARCH", 
        "ansible_os_family": "Arch Linux",
        "ansible_userspace_architecture": "x86_64", 

The content of /etc/os-release:

work (master) ~/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/"

The Ansible version (installed from the Arch Linux repositories):

$ pacman -Q ansible
ansible 2.4.0.0-1

@alikins
Copy link
Contributor

alikins commented Sep 25, 2017

@shakeme

"ansible_distribution_major_version": "NA",
"ansible_distribution_release": "NA",
"ansible_distribution_version": "NA",

As far as I know, this is expected for Arch. If there is a good way to get useful info there, a pr to add it would be great.

alikins added a commit that referenced this issue Sep 25, 2017
* Fix 'distribution' fact for ArchLinux

Allow empty wasn't breaking out of the process_dist_files
loop, so a empty /etc/arch-release would continue searching
and eventually try /etc/os-release. The os-release parsing
works, but the distro name there is 'Arch Linux' which does
not match the 2.3 behavior of 'Archlinux'

Add a OS_RELEASE_ALIAS map for the cases where we need to get
the distro name from os-release but use an alias.

We can't include 'Archlinux' in SEARCH_STRING because a name match on its keys
but without a match on the content causes a fallback to using the first
whitespace seperated item from the file content as the name.
For os-release, that is in form 'NAME=Arch Linux'

With os-release returning the right name, this also supports the
case where there is no /etc/arch-release, but there is a /etc/os-release

Fixes #30600

* pep8 and comment cleanup
alikins added a commit that referenced this issue Sep 25, 2017
Allow empty wasn't breaking out of the process_dist_files
loop, so a empty /etc/arch-release would continue searching
and eventually try /etc/os-release. The os-release parsing
works, but the distro name there is 'Arch Linux' which does
not match the 2.3 behavior of 'Archlinux'

Add a OS_RELEASE_ALIAS map for the cases where we need to get
the distro name from os-release but use an alias.

We can't include 'Archlinux' in SEARCH_STRING because a name match on its keys
but without a match on the content causes a fallback to using the first
whitespace seperated item from the file content as the name.
For os-release, that is in form 'NAME=Arch Linux'

With os-release returning the right name, this also supports the
case where there is no /etc/arch-release, but there is a /etc/os-release

Fixes #30600

* pep8 and comment cleanup

(cherry picked from commit 3eab636)
@alikins
Copy link
Contributor

alikins commented Sep 25, 2017

Fixed in stable-2.4 in 2149d10

prasadkatti pushed a commit to prasadkatti/ansible that referenced this issue Oct 1, 2017
* Fix 'distribution' fact for ArchLinux

Allow empty wasn't breaking out of the process_dist_files
loop, so a empty /etc/arch-release would continue searching
and eventually try /etc/os-release. The os-release parsing
works, but the distro name there is 'Arch Linux' which does
not match the 2.3 behavior of 'Archlinux'

Add a OS_RELEASE_ALIAS map for the cases where we need to get
the distro name from os-release but use an alias.

We can't include 'Archlinux' in SEARCH_STRING because a name match on its keys
but without a match on the content causes a fallback to using the first
whitespace seperated item from the file content as the name.
For os-release, that is in form 'NAME=Arch Linux'

With os-release returning the right name, this also supports the
case where there is no /etc/arch-release, but there is a /etc/os-release

Fixes ansible#30600

* pep8 and comment cleanup
alikins added a commit that referenced this issue Oct 3, 2017
'distribution' facts were being set after checking
the existence of the dist file, and then being set
again with more detail after they were succesfully parsed.

But if the dist file was not succesfully parsed and
matched the required names, the loop continues
without resetting the earlier set facts. This is
how 'Mandriva' would end up being the 'distribution'
file for unrelated cases (it would find /etc/lsb-release,
set distro to 'Mandriva', then fail to parse/match and
continue the loop. If no other checks worked, 'Mandriva'
would stick).

* parse_dist_file_NA should check 'name' not distro for NA

parse_distribution_file_NA was checking the incoming
'distribution' fact to be 'NA', but the fact itself can
be specific at that point ('KDE Neon', for ex) but the
check is really if the 'name' it was passed is NA.

* for matches on OS_RELEASE_ALIAS (ie, 'Archlinux') do
not continue if the dist file content doesn't match. Previously
it had to because of the 'Mandriva' bug mentioned above.

This is a more general fix for #30693 than #30723

Fixes  #30693
Related to #30600
BondAnthony pushed a commit to BondAnthony/ansible that referenced this issue Oct 5, 2017
* Fix 'distribution' fact for ArchLinux

Allow empty wasn't breaking out of the process_dist_files
loop, so a empty /etc/arch-release would continue searching
and eventually try /etc/os-release. The os-release parsing
works, but the distro name there is 'Arch Linux' which does
not match the 2.3 behavior of 'Archlinux'

Add a OS_RELEASE_ALIAS map for the cases where we need to get
the distro name from os-release but use an alias.

We can't include 'Archlinux' in SEARCH_STRING because a name match on its keys
but without a match on the content causes a fallback to using the first
whitespace seperated item from the file content as the name.
For os-release, that is in form 'NAME=Arch Linux'

With os-release returning the right name, this also supports the
case where there is no /etc/arch-release, but there is a /etc/os-release

Fixes ansible#30600

* pep8 and comment cleanup
BondAnthony pushed a commit to BondAnthony/ansible that referenced this issue Oct 5, 2017
'distribution' facts were being set after checking
the existence of the dist file, and then being set
again with more detail after they were succesfully parsed.

But if the dist file was not succesfully parsed and
matched the required names, the loop continues
without resetting the earlier set facts. This is
how 'Mandriva' would end up being the 'distribution'
file for unrelated cases (it would find /etc/lsb-release,
set distro to 'Mandriva', then fail to parse/match and
continue the loop. If no other checks worked, 'Mandriva'
would stick).

* parse_dist_file_NA should check 'name' not distro for NA

parse_distribution_file_NA was checking the incoming
'distribution' fact to be 'NA', but the fact itself can
be specific at that point ('KDE Neon', for ex) but the
check is really if the 'name' it was passed is NA.

* for matches on OS_RELEASE_ALIAS (ie, 'Archlinux') do
not continue if the dist file content doesn't match. Previously
it had to because of the 'Mandriva' bug mentioned above.

This is a more general fix for ansible#30693 than ansible#30723

Fixes  ansible#30693
Related to ansible#30600
@rafi
Copy link

rafi commented Oct 12, 2017

In the meantime, "{{ ansible_distribution | lower | replace(' ', '') }}"

@ironicbadger
Copy link

I'm still seeing this bug in 2.6.2

@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants