Co-authored-by: Florent PIGOUT <toopy@users.noreply.github.com>
This commit is contained in:
parent
7662568bd8
commit
7b3d2a00a0
3 changed files with 30 additions and 0 deletions
2
changelogs/fragments/fix-cron-file-regression.yaml
Normal file
2
changelogs/fragments/fix-cron-file-regression.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- cron - cron file should not be empty after adding var (https://github.com/ansible/ansible/pull/71207)
|
|
@ -255,6 +255,7 @@ class CronTab(object):
|
|||
try:
|
||||
f = open(self.b_cron_file, 'rb')
|
||||
self.n_existing = to_native(f.read(), errors='surrogate_or_strict')
|
||||
self.lines = self.n_existing.splitlines()
|
||||
f.close()
|
||||
except IOError:
|
||||
# cron file does not exist
|
||||
|
|
|
@ -100,6 +100,33 @@
|
|||
- assert:
|
||||
that: remove_cron_file is not changed
|
||||
|
||||
- name: Non regression test - cron file should not be empty after adding var (#71207)
|
||||
when: ansible_distribution != 'Alpine'
|
||||
block:
|
||||
- name: Cron file creation
|
||||
cron:
|
||||
cron_file: cron_filename
|
||||
name: "simple cron job"
|
||||
job: 'echo "_o/"'
|
||||
user: root
|
||||
|
||||
- name: Add var to the cron file
|
||||
cron:
|
||||
cron_file: cron_filename
|
||||
env: yes
|
||||
name: FOO
|
||||
value: bar
|
||||
user: root
|
||||
|
||||
- name: "Ensure cron_file still contains job string"
|
||||
replace:
|
||||
path: /etc/cron.d/cron_filename
|
||||
regexp: "_o/"
|
||||
replace: "OK"
|
||||
register: find_chars
|
||||
failed_when: (find_chars is not changed) or (find_chars is failed)
|
||||
|
||||
# BusyBox does not have /etc/cron.d
|
||||
- name: Removing a cron file when the name is specified is allowed (#57471)
|
||||
block:
|
||||
- name: Cron file creation
|
||||
|
|
Loading…
Reference in a new issue