---
- name: Install latest datadog-agent package (dnf)
  dnf:
    name: "{{ datadog_agent_flavor }}"
    update_cache: yes
    state: latest  # noqa 403
  register: datadog_agent_install
  when: not ansible_check_mode and ansible_facts.python.version.major | int >= 3
  notify: restart datadog-agent

- name: Install latest datadog-agent package (yum)
  yum:
    name: "{{ datadog_agent_flavor }}"
    update_cache: yes
    state: latest  # noqa 403
  register: datadog_agent_install
  when: not ansible_check_mode and ansible_facts.python.version.major | int < 3
  notify: restart datadog-agent
