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

Amazon Linux 2 ansible_distribution_version fact not parsed correctly #48823

Closed
gizmonicus opened this issue Nov 16, 2018 · 8 comments · Fixed by #51521
Closed

Amazon Linux 2 ansible_distribution_version fact not parsed correctly #48823

gizmonicus opened this issue Nov 16, 2018 · 8 comments · Fixed by #51521
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. easyfix This issue is considered easy to fix by aspiring contributors. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@gizmonicus
Copy link

gizmonicus commented Nov 16, 2018

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.

# before the update
Amazon Linux release 2
# after the update
Amazon Linux release 2 (Karoo)

Because this code...

amazon_facts['distribution_version'] = data.split()[-1]

...splits this string on spaces and uses -1 as the index, ansible_distribution_version is set to (Karoo) instead of the expected value 2. 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 when distribution.py was written.

I also noticed that if you remove /etc/system-release you can allow distribution.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 the ansible_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
  • Bug Report
COMPONENT NAME

Ansible facts module

ANSIBLE VERSION
ansible 2.5.10
  config file = /home/cliff/workspace/wfu.ansible/ansible.cfg
  configured module search path = [u'/home/cliff/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/cliff/.virtualenvs/ansible/lib/python2.7/site-packages/ansible
  executable location = /home/cliff/.virtualenvs/ansible/bin/ansible
  python version = 2.7.15 (default, Jun 27 2018, 13:05:28) [GCC 8.1.1 20180531]

CONFIGURATION
DEFAULT_BECOME(/home/user/workspace/ansible/ansible.cfg) = True
DEFAULT_BECOME_USER(/home/user/workspace/ansible/ansible.cfg) = root
DEFAULT_HOST_LIST(/home/user/workspace/ansible/ansible.cfg) = [u'/home/user/workspace/ansible/inventory.yml']
DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /home/user/.ansible-vault
DIFF_ALWAYS(/home/user/workspace/ansible/ansible.cfg) = True
HOST_KEY_CHECKING(/home/user/workspace/ansible/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/user/workspace/ansible/ansible.cfg) = False

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 is 1: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.

@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2018

Hi @gizmonicus, thank you for submitting this issue!

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2018

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Nov 16, 2018
@gundalow gundalow added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed support:community This issue/PR relates to code supported by the Ansible community. labels Nov 22, 2018
@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Nov 22, 2018
@gundalow gundalow added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed support:community This issue/PR relates to code supported by the Ansible community. labels Nov 22, 2018
@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. support:community This issue/PR relates to code supported by the Ansible community. labels Nov 22, 2018
@abadger abadger added P3 Priority 3 - Approved, No Time Limitation easyfix This issue is considered easy to fix by aspiring contributors. and removed needs_triage Needs a first human triage before being processed. labels Nov 27, 2018
@chadmiller-amzn
Copy link

I want to confirm /etc/os_release is the correct file to parse, not the human-legible /etc/system_release.

@tamsky
Copy link
Contributor

tamsky commented Dec 4, 2018

My vote is for /etc/os_release

@jmahler
Copy link
Contributor

jmahler commented Dec 4, 2018

From info here [1] os-release was established by systemd which suggests
it isn't guaranteed to be present on pre-systemd systems.

A solution that uses /etc/os-release if possible and falls back to /etc/system-release
otherwise would avoid potential backward incompatibilities.

[1] http://0pointer.de/blog/projects/os-release.html

@ansibot
Copy link
Contributor

ansibot commented Feb 6, 2019

@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:

  • issue type
  • ansible version
  • component name

Please set the description of this issue with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE.md

click here for bot help

@ansibot ansibot added needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. labels Feb 6, 2019
jmahler added a commit to jmahler/ansible that referenced this issue Feb 6, 2019
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
@ansibot ansibot removed needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. labels Feb 6, 2019
ansibot pushed a commit that referenced this issue Feb 7, 2019
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
@maximede
Copy link
Contributor

maximede commented Jun 4, 2019

Hello ! Would you accept a PR to backport the fix (#51521) in the stable-2.5 branch ?

@mkrizek
Copy link
Contributor

mkrizek commented Jun 5, 2019

@maximede No, 2.5 is EOL. Please see https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#release-status to see status for each Ansible version, thanks!

@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. easyfix This issue is considered easy to fix by aspiring contributors. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
10 participants