summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeni Golov <evgeni@golov.de>2017-02-19 17:51:12 +0100
committerToshio Kuratomi <a.badger@gmail.com>2017-03-28 07:52:02 -0700
commit31a1f19cd8319a9f15fa284bfc5e21a697cf8cb1 (patch)
treee63542485c930f83f12f59144a0760215040d4e1
parent30c0fd27cc0b8a003c60429aac403cb9bab4e9f2 (diff)
downloadansible-modules-core-31a1f19cd8319a9f15fa284bfc5e21a697cf8cb1.tar.gz
cron: don't force changed=True when old crontab was empty
The cron module forces changed=True when there was no real change, but the original crontab did not contain a final newline, which is mandatory. When the user has no crontab or the user does not exist at all, crontab -l exits with 1 and the cron module correctly interprets this as "no crontab" and stores the old crontab as "". However this triggers changed=True, even if we're not going to change anything, e.g. when removing a crontab entry from a user who has no crontabs at all. Let's special-case the fact that the old crontab is empty and not force changed=True in that case. (cherry picked from 61579aebb2bf18dce76c1c39b33a0d7f33ed7073)
-rw-r--r--system/cron.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/system/cron.py b/system/cron.py
index a4784de2..188156ce 100644
--- a/system/cron.py
+++ b/system/cron.py
@@ -668,7 +668,7 @@ def main():
changed = True
# no changes to env/job, but existing crontab needs a terminating newline
- if not changed:
+ if not changed and not crontab.existing == '':
if not (crontab.existing.endswith('\r') or crontab.existing.endswith('\n')):
changed = True