diff --git a/tasks/pkg-redhat.yml b/tasks/pkg-redhat.yml index cc58df4c..765f346f 100644 --- a/tasks/pkg-redhat.yml +++ b/tasks/pkg-redhat.yml @@ -1,4 +1,22 @@ --- +- name: Set upper bound last supported Agent version for Centos < 7 + when: ansible_facts.os_family == "RedHat" + block: + - name: Get RHEL major version equivalent + command: "rpm -E %{rhel}" # noqa: command-instead-of-module + register: rhel_version + changed_when: false + check_mode: false + - name: Set upper agent version bound as ansible fact + set_fact: + datadog_agent_max_minor_version: 51 + when: rhel_version.stdout | int < 7 + +- name: Fail if specified agent version is above maximum supported by Centos < 7 and equivalent + fail: + 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: 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. diff --git a/tasks/pkg-redhat/install-latest.yml b/tasks/pkg-redhat/install-latest.yml index 281d72d0..94aad2ad 100644 --- a/tasks/pkg-redhat/install-latest.yml +++ b/tasks/pkg-redhat/install-latest.yml @@ -1,7 +1,16 @@ --- +- name: Set installation target for latest + set_fact: + # Apply a version cap if required, otherwise just target the agent package + datadog_agent_target: >- + {{ datadog_agent_flavor }} + {% if datadog_agent_max_minor_version is defined %} + < 1:{{ agent_datadog_agent_major_version }}.{{ datadog_agent_max_minor_version + 1 }}.0-1 + {% endif %} + - name: Install latest datadog-agent package (dnf) dnf: - name: "{{ datadog_agent_flavor }}" + name: "{{ datadog_agent_target }}" update_cache: true state: latest # noqa package-latest register: agent_datadog_agent_install @@ -10,7 +19,7 @@ - name: Install latest datadog-agent package (yum) yum: - name: "{{ datadog_agent_flavor }}" + name: "{{ datadog_agent_target }}" update_cache: true state: latest # noqa package-latest register: agent_datadog_agent_install