Skip to content

Commit

Permalink
Fix distribution detection on Amazon Linux 2023 (#612)
Browse files Browse the repository at this point in the history
* add a test to ensure we don't detect amazonlinux as RHEL6

* disable RHEL 6 detection on amazon linux

All the supported version have a recent enough glibc, so we can install
the most recent agents there.
Our RHEL version checking isn't compatible with Amazon linux 2023 which
causes us to prevent installing any version above 7.51 there.

* pin a specific python version for old ansible versions

* don't attempt to use python2 on AL2023

* add debug

* ensure AL2023 will use dnf instead of yum
  • Loading branch information
chouquette authored Sep 20, 2024
1 parent 68e6641 commit f2ed7d4
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
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

0 comments on commit f2ed7d4

Please sign in to comment.