Skip to content

(FACT-3451) Restore os facts for AmazonLinux 2 #2661

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

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

joshcooper
Copy link
Contributor

Commit abba895 changed the os.release and os.distro.release facts on Amazon Linux to query the os-release rpm, effectively running this command:

# rpm -q --qf '%{VERSION}\n' -f /etc/os-release
2023.1.20230912

This was appropriate for AL2023, but it introduced a regression on AL2 because the os.release.major and os.distro.release.major facts changed from "2" to a year-based version like:

# rpm -q --qf '%{VERSION}\n' -f /etc/os-release
2017.12

Since the os.release.major fact changed from 2 to 2017, the systemd service provider was no longer the default on AL2[1]

AL1 was seemingly unaffected because we were already using a year-based version string and both VERSION and VERSION_ID were the same:

# rpm -q --qf '%{VERSION}\n' -f /etc/os-release
2017.03
# grep VERSION_ID /etc/os-release
VERSION_ID="2017.03"

This commit restores the behavior for AL1 and AL2 to use /etc/system-release. On AL2, the major version will be reported as 2 instead of 20xx.

This commit preserves the AL2023 behavior so it uses the os-release rpm to report the major version 2023.

[1] https://github.com/puppetlabs/puppet/blob/8.3.1/lib/puppet/provider/service/systemd.rb#L22

Commit abba895 changed the `os.release` and `os.distro.release` facts on Amazon
Linux to query the os-release rpm, effectively running this command:

    # rpm -q --qf '%{VERSION}\n' -f /etc/os-release
    2023.1.20230912

This was appropriate for AL2023, but it introduced a regression on AL2 because
the `os.release.major` and `os.distro.release.major` facts changed from "2" to
a year-based version like:

    # rpm -q --qf '%{VERSION}\n' -f /etc/os-release
    2017.12

Since the `os.release.major` fact changed from 2 to 2017, the systemd service
provider was no longer the default on AL2[1]

AL1 was seemingly unaffected because we were already using a year-based version
string and both `VERSION` and `VERSION_ID` were the same:

    # rpm -q --qf '%{VERSION}\n' -f /etc/os-release
    2017.03
    # grep VERSION_ID /etc/os-release
    VERSION_ID="2017.03"

This commit restores the behavior for AL1 and AL2 to use `/etc/system-release`.
On AL2, the `major` version will be reported as `2` instead of `20xx`.

This commit preserves the AL2023 behavior so it uses the os-release rpm to
report the `major` version `2023`.

[1] https://github.com/puppetlabs/puppet/blob/8.3.1/lib/puppet/provider/service/systemd.rb#L22
Copy link
Contributor

@amitkarsale amitkarsale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@amitkarsale amitkarsale merged commit 49379df into puppetlabs:main Jan 3, 2024
@joshcooper joshcooper deleted the facter_amazon_2017 branch January 3, 2024 17:17
@joshcooper joshcooper added enhancement New feature or enhancement maintenance Maintenance chores are excluded from changelogs and removed enhancement New feature or enhancement labels Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance chores are excluded from changelogs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants