From c33b157c8bd8ef5420f94617e1f04745d5ab529f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Fri, 13 Sep 2024 11:57:08 +0200 Subject: [PATCH 1/6] add a test to ensure we don't detect amazonlinux as RHEL6 --- .circleci/config.yml | 21 +++++++++++++++++++++ ci_test/install_agent_7_pinned.yaml | 13 +++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 ci_test/install_agent_7_pinned.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index d120e982..7678495e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -356,6 +356,22 @@ 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: + jinja2_native: + type: string + default: "false" + os: + type: string + ansible_version: + type: string + steps: + - checkout + - run: ANSIBLE_JINJA2_NATIVE="<>" ansible-playbook -i ./ci_test/inventory/ci.ini ./ci_test/install_agent_7_pinned.yaml + - run: datadog-agent version workflows: version: 2 @@ -472,3 +488,8 @@ workflows: - test_installer_over_pinned + - test_incorrect_rhel6_detect: + matrix: + parameters: + ansible_version: ["2_10", "3_4", "4_10"] + os: [ "amazonlinux2023"] diff --git a/ci_test/install_agent_7_pinned.yaml b/ci_test/install_agent_7_pinned.yaml new file mode 100644 index 00000000..db9e821f --- /dev/null +++ b/ci_test/install_agent_7_pinned.yaml @@ -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 From f39b07fe9fd86aa412aa3014b08ff244b91e68c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Fri, 13 Sep 2024 13:29:17 +0200 Subject: [PATCH 2/6] 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. --- tasks/pkg-redhat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/pkg-redhat.yml b/tasks/pkg-redhat.yml index f44c7f1b..209bb225 100644 --- a/tasks/pkg-redhat.yml +++ b/tasks/pkg-redhat.yml @@ -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 From a779f3e20a9b663db75cfbe3c2a7db7be8c49543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Fri, 13 Sep 2024 15:02:00 +0200 Subject: [PATCH 3/6] pin a specific python version for old ansible versions --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7678495e..b68b8458 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -366,11 +366,13 @@ jobs: default: "false" os: type: string + python: + type: string ansible_version: type: string steps: - checkout - - run: ANSIBLE_JINJA2_NATIVE="<>" ansible-playbook -i ./ci_test/inventory/ci.ini ./ci_test/install_agent_7_pinned.yaml + - run: ANSIBLE_JINJA2_NATIVE="<>" ansible-playbook -i ./ci_test/inventory/ci.ini ./ci_test/install_agent_7_pinned.yaml -e 'ansible_python_interpreter=/usr/bin/<>' - run: datadog-agent version workflows: @@ -493,3 +495,4 @@ workflows: parameters: ansible_version: ["2_10", "3_4", "4_10"] os: [ "amazonlinux2023"] + python: ["python2"] From abad3ed0c30da2e563ab8b12490f2ebf46016134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Fri, 13 Sep 2024 15:07:37 +0200 Subject: [PATCH 4/6] don't attempt to use python2 on AL2023 --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b68b8458..ad83521d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -366,10 +366,10 @@ jobs: default: "false" os: type: string - python: - type: string ansible_version: type: string + python: + type: string steps: - checkout - run: ANSIBLE_JINJA2_NATIVE="<>" ansible-playbook -i ./ci_test/inventory/ci.ini ./ci_test/install_agent_7_pinned.yaml -e 'ansible_python_interpreter=/usr/bin/<>' @@ -493,6 +493,6 @@ workflows: - test_incorrect_rhel6_detect: matrix: parameters: - ansible_version: ["2_10", "3_4", "4_10"] + ansible_version: ["4_10"] os: [ "amazonlinux2023"] - python: ["python2"] + python: ["python3"] From 2c51115b5102f0cb382ceb88d0ea9d553a0b334b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Mon, 16 Sep 2024 12:50:33 -0400 Subject: [PATCH 5/6] add debug --- tasks/pkg-redhat.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/pkg-redhat.yml b/tasks/pkg-redhat.yml index 209bb225..67b6155f 100644 --- a/tasks/pkg-redhat.yml +++ b/tasks/pkg-redhat.yml @@ -21,6 +21,10 @@ 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 +- name: debug amazon facts + debug: + msg: '{{ ansible_facts }}' + - 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. From 09a1b4e006873e815944b92861c21e11bf0c34bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Mon, 16 Sep 2024 13:03:47 -0400 Subject: [PATCH 6/6] ensure AL2023 will use dnf instead of yum --- tasks/pkg-redhat.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tasks/pkg-redhat.yml b/tasks/pkg-redhat.yml index 67b6155f..37b76c46 100644 --- a/tasks/pkg-redhat.yml +++ b/tasks/pkg-redhat.yml @@ -21,9 +21,12 @@ 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 -- name: debug amazon facts - debug: - msg: '{{ ansible_facts }}' + # 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: