Skip to content


Fix crontab argument order for writing (#3750)
Browse files Browse the repository at this point in the history
Currently, when writing user's crontab, ansible calls

    crontab <file> -u <user>

This is incorrect according to crontab(1) on both FreeBSD and Linux,
which suggest that file argument should be the last.

At least on FreeBSD, this leads to incorrect cron module bahavior which
writes to root's crontab instead of users's
  • Loading branch information
AMDmi3 authored and mattclay committed Dec 8, 2016
1 parent 3ae6583 commit 13d7a61
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ansible/modules/system/
Expand Up @@ -488,7 +488,7 @@ def _write_execute(self, path):
return "chown %s %s ; su '%s' -c '%s %s'" % (pipes.quote(self.user), pipes.quote(path), pipes.quote(self.user), CRONCMD, pipes.quote(path))
user = '-u %s' % pipes.quote(self.user)
return "%s %s %s" % (CRONCMD , pipes.quote(path), user)
return "%s %s %s" % (CRONCMD , user, pipes.quote(path))

Expand Down

0 comments on commit 13d7a61

Please sign in to comment.