Add crontab_renew.yml

This commit is contained in:
2026-04-29 09:38:34 +01:00
parent d3f411f444
commit fb92d5deda
+32
View File
@@ -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