From 1f7d1577dc5bf2da52d0b969703fdcfed6cb0754 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 12 Feb 2024 16:32:21 +0100 Subject: [PATCH] Update the apt cache when the repo changes. --- tasks/main.yml | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 9c9d274..68ca348 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,25 +1,4 @@ --- -- name: Remove grafana - when: not grafana_enabled - tags: [grafana] - block: - - name: Ensure that grafana is stopped and disabled - ansible.builtin.service: - name: grafana-server - state: stopped - enabled: false - - - name: Remove the grafana deb packages - ansible.builtin.apt: - name: "{{ grafana_packages }}" - state: absent - - - name: Install the grafana deb repository - ansible.builtin.apt_repository: - repo: '{{ grafana_repo }}' - state: absent - update_cache: true - - name: Install grafana when: grafana_enabled tags: [grafana] @@ -49,6 +28,11 @@ signed_by: "{{ grafana_repo_key_file }}" state: present enabled: true + register: grafana_repo + - name: Update the apt cache + ansible.builtin.apt: + update_cache: yes + when: grafana_repo is changed - name: Install the grafana packages ansible.builtin.apt: pkg: "{{ grafana_packages }}"