-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Amazon Linux 2 ansible_distribution_version fact not parsed correctly #48823
Comments
Hi @gizmonicus, thank you for submitting this issue! |
Files identified in the description: If these files are inaccurate, please update the |
I want to confirm |
My vote is for |
From info here [1] os-release was established by systemd which suggests A solution that uses /etc/os-release if possible and falls back to /etc/system-release |
@gizmonicus: Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information. Here are the items we could not find in your description:
Please set the description of this issue with this template: |
Previously it was assumed that the Amazon system-release number was the final value of the string. This isn't always the case. Some releases have the name at the end. Amazon Linux release 2 Amazon Linux release 2 (Karoo) Fix by instead looking for a number in the string. Fixes ansible#48823
Previously it was assumed that the Amazon system-release number was the final value of the string. This isn't always the case. Some releases have the name at the end. Amazon Linux release 2 Amazon Linux release 2 (Karoo) Fix by instead looking for a number in the string. Fixes #48823
Hello ! Would you accept a PR to backport the fix (#51521) in the |
@maximede No, |
SUMMARY
Amazon Linux 2 has changed the string they use in the
/etc/system-release
file. Previously, it did not have a "codename", but it does now. This breaks ansible_distribution_version fact.Because this code...
ansible/lib/ansible/module_utils/facts/system/distribution.py
Line 224 in c5b303f
...splits this string on spaces and uses -1 as the index,
ansible_distribution_version
is set to(Karoo)
instead of the expected value2
. I am using ansible 2.5.10, but have confirmed the master branch has the same code for parsing the Amazon Linux version number.I have noticed that Amazon Linux and Amazon Linux 2 both now have an
/etc/os-release
file that looks like it would be easier to parse and less prone to breakage when these types of changes occur. I suspect that wasn't the case whendistribution.py
was written.I also noticed that if you remove
/etc/system-release
you can allowdistribution.py
to fall back to the default parser mode, and it is able to correctly determine the version in both cases (Amazon Linux 1/2), but theansible_distribution_name
does not get correctly set. I've looked into modifying the code to support/etc/os-release
parsing on Amazon Linux distributions, but have not been successful yet.ISSUE TYPE
COMPONENT NAME
Ansible facts module
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Target OS: AWS Amazon Linux 2
Kernel: 4.14.72-73.55.amzn2.x86_64
The package containing the new
/etc/system-release
file is1:system-release-2-7.amzn2.x86_64
.STEPS TO REPRODUCE
To reproduce, spin up an AWS EC2 instance with Amazon Linux 2 installed. Be sure the package mentioned in the OS / Environment section is installed. Then run:
ansible -m setup hostname | grep ansible_distribution_version
EXPECTED RESULTS
We expect to see
2
as the version number.ACTUAL RESULTS
You will see
(karoo)
as the version.The text was updated successfully, but these errors were encountered: