Skip to content

Commit

Permalink
feat: improvements to repo cache handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Apr 21, 2024
1 parent c7e5b94 commit 11d788f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
13 changes: 13 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@
become: true
ansible.builtin.apt:
update_cache: true
when: ansible_pkg_mgr == "apt"

- name: "Update dnf cache"
become: true
ansible.builtin.dnf:
update_cache: true
when: ansible_pkg_mgr == "dnf"

- name: "Update yum cache"
become: true
ansible.builtin.yum:
update_cache: true
when: ansible_pkg_mgr == "yum"
13 changes: 8 additions & 5 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,32 @@
cache_valid_time: 3600
when: ansible_pkg_mgr == "apt"

- name: "Ensure netdata is installed (yum)"
ansible.builtin.yum:
- name: "Ensure netdata is installed (dnf)"
ansible.builtin.dnf:
name:
- util-linux
- openssl
- netdata
state: present
when: ansible_pkg_mgr == "yum"
update_cache: true
when: ansible_pkg_mgr == "dnf"

- name: "Ensure netdata is installed (dnf)"
- name: "Ensure netdata is installed (yum)"
ansible.builtin.yum:
name:
- util-linux
- openssl
- netdata
state: present
when: ansible_pkg_mgr == "dnf"
update_cache: true
when: ansible_pkg_mgr == "yum"

- name: "Ensure netdata is installed (zypper)"
community.general.zypper:
name:
- netdata
state: present
update_cache: true
when: ansible_pkg_mgr == "zypper"

- name: "Ensure netdata is started"
Expand Down
4 changes: 3 additions & 1 deletion tasks/repo-Debian.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
- name: "Ensure netdata-repo is removed (Debian Family) [Legacy]"
become: true
ansible.builtin.apt:
name:
- netdata-repo
Expand All @@ -23,17 +22,20 @@
repo: "deb http://repo.netdata.cloud/repos/stable/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release | lower }}/"
state: absent
filename: netdata-stable
notify: "Update apt cache"

- name: "Ensure netdata repository is removed (Debian Family) [Legacy]: edge"
ansible.builtin.apt_repository:
repo: "deb http://repo.netdata.cloud/repos/edge}/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release | lower }}/"
state: absent
filename: netdata-edge
notify: "Update apt cache"

- name: "Ensure netdata repo key is removed from legacy trusted.gpg keyring (Debian Family) [Legacy]"
ansible.builtin.apt_key:
state: absent
id: 0x6588FDD7B14721FE7C3115E6F9177B5265F56346
notify: "Update apt cache"

- name: "Set fact netdata_agent_channel_remove to edge"
ansible.builtin.set_fact:
Expand Down
9 changes: 9 additions & 0 deletions tasks/repo-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@
- netdata-repo
- netdata-repo-edge
state: absent
notify:
- "Update dnf cache"
- "Update yum cache"

- name: "Add netdata repository"
when: netdata_agent_state == "present"
notify:
- "Update dnf cache"
- "Update yum cache"
block:
- name: "Ensure netdata repo key is present (RedHat Family)"
ansible.builtin.rpm_key:
Expand Down Expand Up @@ -77,6 +83,9 @@

- name: "Remove netdata repository"
when: netdata_agent_state == "absent"
notify:
- "Update dnf cache"
- "Update yum cache"
block:
- name: "Ensure netdata repository is removed (RedHat Family): stable"
ansible.builtin.yum_repository:
Expand Down

0 comments on commit 11d788f

Please sign in to comment.