From 9a97b43cbf8a9596fb4e27f18404aa69499410a7 Mon Sep 17 00:00:00 2001 From: phil Date: Mon, 6 Feb 2023 22:51:32 +0100 Subject: [PATCH] Run tasks only when packages are installed --- tasks/monitoring.yml | 3 +++ tasks/packages.yml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/tasks/monitoring.yml b/tasks/monitoring.yml index 49b975f..a1e02dc 100644 --- a/tasks/monitoring.yml +++ b/tasks/monitoring.yml @@ -22,6 +22,7 @@ src: munin_configuration dest: /etc/munin/plugin-conf.d/yyy-apache mode: 0644 + when: munin in ansible_facts.packages notify: restart munin-node - name: "Monitoring | Enable Munin plugins" @@ -33,6 +34,7 @@ - apache_accesses - apache_processes - apache_volume + when: munin in ansible_facts.packages notify: restart munin-node - name: "Monitoring | Enable Monit configuration" @@ -40,4 +42,5 @@ src: monit.conf dest: /etc/monit/conf-enabled/apache2 mode: 0644 + when: monit in ansible_facts.packages notify: reload monit diff --git a/tasks/packages.yml b/tasks/packages.yml index 5c99b7c..1a38197 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -1,4 +1,8 @@ --- +- name: "Packages | Get installed packages" + ansible.builtin.package_facts: + manager: apt + - name: "Packages | Install packages" ansible.builtin.apt: pkg: