Skip to content

Commit

Permalink
Do not name the RPM repo file differently depending on the Agent vers…
Browse files Browse the repository at this point in the history
…ion (#311)

Use datadog.repo as the name, to be consistent with other install methods.
  • Loading branch information
albertvaka authored Dec 4, 2020
1 parent 808c84e commit 314b32f
Showing 1 changed file with 45 additions and 14 deletions.
59 changes: 45 additions & 14 deletions tasks/pkg-redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,63 @@
state: present
when: not ansible_check_mode

- name: Install Datadog yum repo
- name: Install Datadog Agent 5 yum repo
yum_repository:
name: "ansible_datadog_{{ item.key }}"
name: datadog
description: Datadog, Inc.
baseurl: "{{ item.value }}"
baseurl: "{{ datadog_agent5_yum_repo }}"
enabled: yes
gpgcheck: yes
gpgkey: "{% if datadog_agent_major_version|int == 7 %}{{ datadog_yum_gpgkey_20200908 }}{% else %}{{ datadog_yum_gpgkey }}{% endif %}"
state: "{% if item.key == datadog_agent_major_version|int and datadog_yum_repo | length == 0 %}present{% else %}absent{% endif %}"
when: (not ansible_check_mode)
with_dict:
5: '{{ datadog_agent5_yum_repo }}'
6: '{{ datadog_agent6_yum_repo }}'
7: '{{ datadog_agent7_yum_repo }}'

- name: (Custom) Install Datadog yum repo
gpgkey: "{{ datadog_yum_gpgkey }}"
register: repofile5
when: (datadog_agent_major_version|int == 5) and (datadog_yum_repo | length == 0) and (not ansible_check_mode)

- name: Install Datadog Agent 6 yum repo
yum_repository:
name: ansible_datadog_custom
name: datadog
description: Datadog, Inc.
baseurl: "{{ datadog_agent6_yum_repo }}"
enabled: yes
gpgcheck: yes
gpgkey: "{{ datadog_yum_gpgkey }}"
register: repofile6
when: (datadog_agent_major_version|int == 6) and (datadog_yum_repo | length == 0) and (not ansible_check_mode)

- name: Install Datadog Agent 7 yum repo
yum_repository:
name: datadog
description: Datadog, Inc.
baseurl: "{{ datadog_agent7_yum_repo }}"
enabled: yes
gpgcheck: yes
gpgkey: "{{ datadog_yum_gpgkey_20200908 }}"
register: repofile7
when: (datadog_agent_major_version|int == 7) and (datadog_yum_repo | length == 0) and (not ansible_check_mode)

- name: Install Datadog Custom yum repo
yum_repository:
name: datadog
description: Datadog, Inc.
baseurl: "{{ datadog_yum_repo }}"
enabled: yes
gpgcheck: yes
gpgkey: "{{ datadog_yum_gpgkey }}"
state: present
register: repofilecustom
when: (datadog_yum_repo | length > 0) and (not ansible_check_mode)

- name: Clean repo metadata if repo changed # noqa 503
command: yum clean metadata --disablerepo="*" --enablerepo=datadog
ignore_errors: yes # Cleaning the metadata is only needed when downgrading a major version of the Agent, don't fail because of this
args:
warn: no
when: repofile5.changed or repofile6.changed or repofile7.changed or repofilecustom.changed

- name: Remove old yum repo files
yum_repository:
name: "ansible_datadog_{{ item }}"
state: absent
with_items: [ 5, 6, 7, "custom" ]

- include_tasks: pkg-redhat/install-pinned.yml
when: datadog_agent_redhat_version is defined

Expand Down

0 comments on commit 314b32f

Please sign in to comment.