Skip to content
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

Limit the versions of the agent that can be installed on Centos < 7 #556

Merged
merged 5 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 15 additions & 0 deletions tasks/os-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@
fail:
msg: "The Datadog Ansible role does not support your OS yet. Please email support@datadoghq.com to open a feature request."
when: ansible_facts.os_family not in ["RedHat", "Rocky", "AlmaLinux", "Debian", "Suse", "Windows", "Darwin"]

- name: 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this is interesting, I never thought about doing this. Have you tested on e.g. Scientific Linux 6? I feel like there might be rhel-6 based distros where this macro wouldn't expand, but I'm not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did a quick test on a Scientific Linux 6 box and it did expand as expected (to 6). Would you say it's safer to use something else (or at least to have some sort of fallback)?

register: rhel_version
changed_when: false
check_mode: false
- name: Set upper agent version bound as ansible fact
set_fact:
datadog_agent_max_version:
full: "{{ datadog_agent_major_version | default('7', true) }}.51.1"
alopezz marked this conversation as resolved.
Show resolved Hide resolved
minor: 51
when: rhel_version.stdout | int < 7
10 changes: 10 additions & 0 deletions tasks/set-parse-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
set_fact:
agent_datadog_skip_install: false

- name: Apply upper bound for last supported Agent version when latest version is expected
set_fact:
datadog_agent_version: "{{ datadog_agent_max_version.full }}"
when: datadog_agent_max_version is defined and datadog_agent_version | length == 0

- name: Include parse version tasks
include_tasks: parse-version.yml
when: datadog_agent_version | default('', true) | length > 0

- name: Fail if specified agent version is above maximum supported by OS
fail:
msg: "Agent versions {{ agent_datadog_major }}.{{ datadog_agent_max_version.minor + 1 }} and above not supported by current OS."
when: datadog_agent_max_version is defined and agent_datadog_minor | int > datadog_agent_max_version.minor

- name: Set Agent default major version
set_fact:
agent_datadog_agent_major_version: "7"
Expand Down