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

Do not name the RPM repo file differently depending on the Agent version #311

Merged
merged 4 commits into from
Dec 4, 2020
Merged
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
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 }}.repo"
state: absent
with_items: [ 5, 6, 7, "custom" ]

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

Expand Down