Commit Graph

32 Commits (12a7027c49f03e969f219bab816bfb928005bacf)

Author SHA1 Message Date
Gregor Giesen 2f3fdc4975 cron: replacement for os.getlogin() (#4777)
os.getlogin() returns the user logged in on the controlling terminal. However
'crontab' only looks for the login name of the process' real user id which
pwd.getpwuid(os.getuid())[0] does provide.

While in most cases there is no difference, the former might fail under certain
circumstances (e.g. a lxc container connected by attachment without login),
throwing the error 'OSError: [Errno 25] Inappropriate ioctl for device'.
8 years ago
Evan Kaufman 4905ab66d6 Fixes #3791 cron always returning changed state for multiline jobs (#4285)
Strip only newlines and carriage returns. Instead of stripping ALL whitespace, which may have unintended side effects
8 years ago
BradLook 7c4de52693 Allow cron to target remote user (#4270) 8 years ago
Thomas Quinot 00fb13010c Clarify behaviour when state=present and no name is given (#3904) 8 years ago
Erik Nadel 7491a11581 Added statement about escaping characters in chron tasks (#3770) 8 years ago
Dmitry Marakasov 68cb864aad Fix crontab argument order for writing (#3750)
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
8 years ago
Michael Scherer afce9e5855 Port cron to a py3 and py24 compatible syntax (#3674) 8 years ago
Tobias Wolf 0edf689688 Add diff and check mode to cron module
supports not writing backup file in check mode and new environment
vars.

![example screenshot](http://i.imgur.com/mkAThq8.png)
9 years ago
Brian Coca 8baecece22 corrected version added 9 years ago
Brian Coca f0f8d27bff Merge pull request #2010 from lberruti/global_user_crontab_env_variables_rebase
cron module: add enviroment variables management
9 years ago
Luca Berruti d820be81e5 Typo. 9 years ago
Brian Coca 493f06435c Merge pull request #2768 from quinot/topic/abs_cron_file
Allow cron_file to be an absolute path
9 years ago
Luca Berruti 933a44ba78 cron module: add enviroment variables management 9 years ago
Brian Coca 7a0b488244 reverse order of cron commands
does not affect linux but fixes issue with busybox caring about order
fixes #2807
9 years ago
Jeroen Seegers 1a362cdff0 Update cron.py
Minor update to documentation for the cron module to reflect the required "name" parameter when the value of "state" is "absent".
9 years ago
Thomas Quinot 0b38e4b407 Allow cron_file to be an absolute path
Support specifying an absolute path (typically /etc/crontab) rather than
a path relative to /etc/cron.d, to allow modifying the main system crontab.
Particularly useful for target systems that have /etc/crontab but no
/etc/cron.d.
9 years ago
Achilleas Pipinellis 1499288c64 Add missing documentation: cron_file requires user to be set 9 years ago
Brian Coca a15aa09251 removed typo 9 years ago
Brian Coca f6bbd2ac5b removed syslog in favor of common module logging functions 9 years ago
Brian Coca 81a7243bbb changed chmod to 2.4 compat 9 years ago
Brian Coca 813053c51c Merge pull request #986 from ssssam/cron-permissions-fix
Fix permissions issue with 'cron' module
9 years ago
Brian Coca 6d7428527d minor doc fixes 9 years ago
Evan Kaufman 1187399ffa Add disabled option to cron module 9 years ago
Brian Coca fed5ff04a6 Merge pull request #742 from aseigneurin/fix-remove-cron_file
Name parameter should not be marked as mandatory
9 years ago
Greg DeKoenigsberg 2a5f0bde87 Proper author info for all remaining modules 9 years ago
Toshio Kuratomi 8d2fdf2aff Update the cron docs to specify that it takes a boolean value 9 years ago
Toshio Kuratomi 4106047e77 Fix documentation of the variable that backup file name is returned in 9 years ago
Michael Scherer a4d7ebc12a Name is a required parameter, fix https://github.com/ansible/ansible/issues/10335 10 years ago
Sam Thursfield adf1cba745 Fix permissions issue with 'cron' module
I have a task like this in a playbook. The ansible_ssh_user is 'root'
for this host.

    - cron:
        hour: 00
        job: /home/backup/backup.sh
        name: baserock.org data backup
        user: backup

Running it gave me the following error:

    TASK: [backup cron job, runs every day at midnight] ***************************
    failed: [baserock-backup1] => {"failed": true}
    msg: crontab: can't open '/tmp/crontabvVjoZe': Permission denied
    crontab: user backup cannot read /tmp/crontabvVjoZe

The temporary file created by the 'cron' module is created with the
Python tempfile.mkstemp() function. This creates a file that is readable
only by 'root' (mode 600). The Busybox `crontab` program then checks if
the file is readable by the 'backup' user, and fails if it isn't. So we
need to make sure the file is world-readable before running `crontab`.
10 years ago
Alexis Seigneurin 6d6e948f1e - 'name' should not be required so as to allow uninstalling a cron_file 10 years ago
Toshio Kuratomi 799a75580a Update cron example for setting to run twice a day
Fixes #415
10 years ago
Michael DeHaan c8e1a2077e file extensions! 10 years ago