Skip to content

Fix distribution detection on Amazon Linux 2023 #612

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 6 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,24 @@ jobs:
- run: >
ansible-playbook -v -i ./ci_test/inventory/ci.ini "./ci_test/install_installer_over_pinned.yaml"

test_incorrect_rhel6_detect:
# Ensure some RHEL derivatives aren't incorrectly detected as RHEL 6
docker:
- image: datadog/docker-library:ansible_<<parameters.os>>_<<parameters.ansible_version>>
parameters:
jinja2_native:
type: string
default: "false"
os:
type: string
ansible_version:
type: string
python:
type: string
steps:
- checkout
- run: ANSIBLE_JINJA2_NATIVE="<<parameters.jinja2_native>>" ansible-playbook -i ./ci_test/inventory/ci.ini ./ci_test/install_agent_7_pinned.yaml -e 'ansible_python_interpreter=/usr/bin/<<parameters.python>>'
- run: datadog-agent version

workflows:
version: 2
Expand Down Expand Up @@ -472,3 +490,9 @@ workflows:

- test_installer_over_pinned

- test_incorrect_rhel6_detect:
matrix:
parameters:
ansible_version: ["4_10"]
os: [ "amazonlinux2023"]
python: ["python3"]
13 changes: 13 additions & 0 deletions ci_test/install_agent_7_pinned.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

- hosts: all
roles:
- { role: '/root/project/'}
vars:
datadog_api_key: "11111111111111111111111111111111"
datadog_enabled: false
# Target a version above 7.51 which is the last version supported on RHEL6 and similar
# This is to ensure we don't incorrectly detect some configurations as RHEL6
datadog_agent_version: '7.53.0'
# avoid checking that the agent is stopped for centos
datadog_skip_running_check: true
9 changes: 8 additions & 1 deletion tasks/pkg-redhat.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Check for Centos < 7 and adjust features
when: ansible_facts.os_family == "RedHat"
when: ansible_facts.os_family == "RedHat" and ansible_distribution != "Amazon"
block:
- name: Get RHEL major version equivalent
command: "rpm -E %{rhel}" # noqa: command-instead-of-module
Expand All @@ -21,6 +21,13 @@
msg: "Agent versions {{ agent_datadog_major }}.{{ datadog_agent_max_minor_version + 1 }} and above not supported by current OS (RHEL < 7 equivalent)."
when: datadog_agent_max_minor_version is defined and agent_datadog_minor is defined and agent_datadog_minor | int > datadog_agent_max_minor_version

# Some ansible versions appear to detect yum as the wanted package manager on AL2023.
# This can't work since AL2023 only ships python3 and the yum module needs python2
- name: Ensure dnf is used on Amazon Linux 2023
set_fact:
ansible_pkg_mgr: dnf
when: ansible_facts.distribution == "Amazon" and ansible_facts.distribution_major_version | int >= 2023 and ansible_pkg_mgr == "yum"

- name: Fail early if Python 3 is used on CentOS / RHEL < 8 with old Ansible
fail:
msg: "The installation of the Agent on RedHat family systems using yum is not compatible with Python 3 with older Ansible versions.
Expand Down