From fb92d5dedadb35cfeeabad6f0204b27f18de789f Mon Sep 17 00:00:00 2001 From: kris Date: Wed, 29 Apr 2026 09:38:34 +0100 Subject: [PATCH] Add crontab_renew.yml --- crontab_renew.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 crontab_renew.yml diff --git a/crontab_renew.yml b/crontab_renew.yml new file mode 100644 index 0000000..66eaf33 --- /dev/null +++ b/crontab_renew.yml @@ -0,0 +1,32 @@ +--- +- name: Comment out certbot renew line in root crontab + hosts: all + become: true + + tasks: + - name: Read current root crontab + ansible.builtin.command: crontab -l -u root + register: root_crontab + changed_when: false + failed_when: root_crontab.rc not in [0, 1] + + - name: Comment out certbot renew line + ansible.builtin.copy: + content: >- + {{ + root_crontab.stdout_lines + | map('regex_replace', '^(?!#)(.*certbot renew -q --force-renewal.*)$', '#\1') + | join('\n') + }}{{ '\n' }} + dest: /tmp/root_crontab_modified + mode: '0600' + when: root_crontab.rc == 0 + + - name: Install modified crontab + ansible.builtin.command: crontab -u root /tmp/root_crontab_modified + when: root_crontab.rc == 0 + + - name: Remove temporary crontab file + ansible.builtin.file: + path: /tmp/root_crontab_modified + state: absent \ No newline at end of file