aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-08-29 21:04:54 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-08-29 21:05:25 +0200
commitb3e8f48d717a4fc046d91dd54df1d9b17177b3a3 (patch)
tree3b520d56107e1baa338c39dcc85a5d3f05e0043d
parentapt_repo: always overwrite the .list file (diff)
downloadinfra-ansible-b3e8f48d717a4fc046d91dd54df1d9b17177b3a3.tar.gz
infra-ansible-b3e8f48d717a4fc046d91dd54df1d9b17177b3a3.zip
apt_repo: run apt update on key changes as well
-rw-r--r--roles/apt_repo/handlers/main.yml5
-rw-r--r--roles/apt_repo/tasks/main.yml9
2 files changed, 9 insertions, 5 deletions
diff --git a/roles/apt_repo/handlers/main.yml b/roles/apt_repo/handlers/main.yml
new file mode 100644
index 0000000..384682b
--- /dev/null
+++ b/roles/apt_repo/handlers/main.yml
@@ -0,0 +1,5 @@
+- name: Refresh apt repositories
+ become: true
+ ansible.builtin.apt:
+ update_cache: true
+ listen: apt_repo_update
diff --git a/roles/apt_repo/tasks/main.yml b/roles/apt_repo/tasks/main.yml
index b6779fd..3e87d38 100644
--- a/roles/apt_repo/tasks/main.yml
+++ b/roles/apt_repo/tasks/main.yml
@@ -18,6 +18,7 @@
url: '{{ apt_repo_key_url }}'
dest: '{{ key_path }}'
mode: '644'
+ notify: apt_repo_update
- name: Get host distro
ansible.builtin.setup:
@@ -33,9 +34,7 @@
owner: root
group: root
mode: '644'
- register: repo_file
+ notify: apt_repo_update
- - name: Refresh apt repositories
- ansible.builtin.apt:
- update_cache: true
- when: repo_file.changed
+ - name: Refresh apt repositories if necessary
+ ansible.builtin.meta: flush_handlers