From 244d6d739f92d8d29d38f6af2995d1e30093c86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20R=C3=B8nningen?= Date: Tue, 4 Dec 2018 11:55:25 +0100 Subject: [PATCH] Allow renew-cron to remove cronjob if it was added earlier If the `certbot_auto_renew` variable was `True`, and the cronjob was added, setting it to `False` would not remove it. By always including the `renew-cron.yml` task file, and instead checking the `certbot_auto_renew` value there, and pick a value for `state` based on it, we can clean up a cronjob if it is no longer wanted. --- tasks/main.yml | 1 - tasks/renew-cron.yml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 680aeda..d3715de 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,4 +16,3 @@ loop_var: cert_item - import_tasks: renew-cron.yml - when: certbot_auto_renew diff --git a/tasks/renew-cron.yml b/tasks/renew-cron.yml index 394a30e..f57dc1a 100644 --- a/tasks/renew-cron.yml +++ b/tasks/renew-cron.yml @@ -6,3 +6,4 @@ minute: "{{ certbot_auto_renew_minute }}" hour: "{{ certbot_auto_renew_hour }}" user: "{{ certbot_auto_renew_user }}" + state: "{{ 'present' if certbot_auto_renew else 'absent' }}"