DataDog / ansible-datadog

Ansible role for Datadog Agent
Apache License 2.0
297 stars 222 forks source link

Add support for Amazon Linux 2023 #543

Closed aairey closed 6 months ago

aairey commented 6 months ago

The role fails to run on Amazon Linux 2023 (Fedora based) OS.

TASK [Datadog.datadog : Fail if OS is not supported] ***************************
fatal: [default]: FAILED! => {"msg": "The conditional check 'ansible_facts.os_family not in [\"RedHat\", \"Rocky\", \"AlmaLinux\", \"Debian\", \"Suse\", \"Windows\", \"Darwin\"]' failed. The error was: error while evaluating conditional (ansible_facts.os_family not in [\"RedHat\", \"Rocky\", \"AlmaLinux\", \"Debian\", \"Suse\", \"Windows\", \"Darwin\"]): 'dict object' has no attribute 'os_family'\n\nThe error appears to be in '/home/aairey/git_projects/trimbletl/aws-ami/provision/ansible/roles/Datadog.datadog/tasks/os-check.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Fail if OS is not supported\n  ^ here\n"}
Pythyu commented 6 months ago

Hey 👋 Thanks for reporting the issue ! With this error 'dict object' has no attribute 'os_family', I suspect the issue might be on your local ansible 🤔 Could you try this playbook ? It'll simply check if your ansible can gather os_family correctly.

---
- hosts: all
  gather_facts: yes
  connection: local
  tasks:
    - debug:
        msg: "{{ ansible_facts.os_family }}"

You should expect something like that :


PLAY [all] ***********************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************
[WARNING]: Platform linux on host localhost is using the discovered Python interpreter at /usr/bin/python3.9, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible-core/2.15/reference_appendices/interpreter_discovery.html for more information.
ok: [localhost]

TASK [debug] *********************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "RedHat"
}

PLAY RECAP ***********************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

If it's working as expected you can try to add gather_facts: yes to your playbook and see if it fixes your issue with the datadog role

aairey commented 6 months ago

Sorry, noticed that later on but still it was picking yum instead of dnf as ansible_pkg_mgr.

I was running ansible-core 2.13 though, after more searching and upgrading to 2.16 it worked! 👍🏻