Commit Graph

46 Commits (921bc0599b62e363c3b9a45d525431215bb56fd2)

Author SHA1 Message Date
Abhijeet Kasurde 301cbc1f5b Remove unreachable code from cron module (#25577)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-06-11 07:35:46 +02:00
Evan Kaufman b244397a31 Cron - Explicitly fail on Solaris when given a special_time (#24898)
* Added explicit failure on Solaris given a special_time

Fixes ansible/ansible#22145

* Using get_platform from module utils
2017-06-02 00:04:12 +02:00
Evan Kaufman ce584571e8 Fixed backup file behavior in check mode (#24899)
Fixes ansible/ansible#21523
2017-05-26 16:16:15 +02:00
Dylan Silva bba4549b43 Downgraded more modules from Curated to Community (#24751) 2017-05-18 08:28:41 -07:00
Evgeni Golov 61579aebb2 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.
2017-03-28 07:45:13 -07:00
Toshio Kuratomi eb1214baad New metadata 1.0 (#22587)
Changes to the metadata format were approved here:
https://github.com/ansible/proposals/issues/54
* Update documentation to the new metadata format
* Changes to metadata-tool to account for new metadata
  * Add GPL license header
  * Add upgrade subcommand to upgrade metadata version
  * Change default metadata to the new format
  * Fix exclusion of non-modules from the metadata report
* Fix ansible-doc for new module metadata
* Exclude metadata version from ansible-doc output
* Fix website docs generation for the new metadata
* Update metadata schema in valiate-modules test
* Update the metadata in all modules to the new version
2017-03-14 09:07:22 -07:00
Matt Clay 10d9318de7 PEP 8 indent cleanup. (#20800)
* PEP 8 E121 cleanup.

* PEP 8 E126 cleanup.

* PEP 8 E122 cleanup.
2017-01-29 07:28:53 +00:00
Evan Kaufman ad9c25a54f Apply SELinux context only if cron_file param exists
Use selinux calls in module_utils/basic instead of native selinux bindings

Fixes #18768
2017-01-09 14:02:05 -05:00
James Cammarata 8afa090417 Resolving differences in core modules post-merge 2016-12-08 11:25:36 -05:00
Toshio Kuratomi 7319104552 Refreshed metadata for core modules 2016-12-08 11:25:35 -05:00
Fabio Alessandro Locati a6cd0272fb Call main in conditional way - system 2016-12-08 11:25:35 -05:00
Evan Kaufman 580c74140a Fix for python 2.4 compatibility (#5693)
Fixes #5692
2016-12-08 11:25:34 -05:00
ekultails 0358919db8 add correct SELinux file context for crontabs (#4511) (#4595) 2016-12-08 11:25:33 -05:00
Sam Doran b56a9852ee Examples syntax batch4 (#5620)
* Change example syntax on authorized_key module

* Change example syntax on cron module

* Change example syntax on group module

* Change example syntax on hostname module

* Change example syntax on seboolean module

* Change example syntax on selinux module

* Change example syntax on service module

* Change example syntax on sysctl module

* Change example syntax on systemd module

* Change example syntax on user module

* Change example syntax on debug module

* Change example syntax on fail module

* Change example syntax on include module

* Change example syntax on include_role module

* Change example syntax on include_vars module

* Change example syntax on pause module

* Change example syntax on wait_for module

* Change example syntax on apache2_module module

* > Change example syntax on django_manage module

* Change example syntax on htpasswd module
2016-12-08 11:25:31 -05:00
Evan Kaufman 5d3e64b0d2 Identify existing unmanaged jobs by exact match, when no header comment is found
* updated `find_job` method to find by exact match of job, when no matching header comment is found
  * note this fallback injects a header comment for later calls to `update_job` or `remove_job`
* abstracted header comment building to `do_comment` method

Fixes #3256
2016-12-08 11:25:25 -05:00
Evan Kaufman f8dad7130d Record existing cron file as string property, rather than only recording termination
This seems less hackish, and feels more proper for diff generation
2016-12-08 11:25:24 -05:00
Evan Kaufman f64990df02 Rendering of crontab should reflect actual newline termination, in diff mode 2016-12-08 11:25:24 -05:00
Evan Kaufman b416015634 Ensure trailing newline is written to cron file
Records whether existing cron file (or CRONCMD output) has a terminating newline, and ensures a trailing newline is written as necessary EVEN IF NO CHANGE WAS MADE to the target env/job

Fixes #2316
2016-12-08 11:25:23 -05:00
Steven de Vries 054fe53b43 Move job parameter to meet expected requirements (#5151)
closes #5273
2016-12-08 11:25:21 -05:00
John R Barker 25b6492d37 Bulk spelling improvement to modules-core (#5225)
* Correct spelling mistakes

* Correct more spelling issues

* merge conflict

* Revert typo in parms
2016-12-08 11:25:20 -05:00
Gregor Giesen b87ef7772f 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'.
2016-12-08 11:25:04 -05:00
Evan Kaufman 3a44d60fbc 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
2016-12-08 11:24:49 -05:00
BradLook 766413e79d Allow cron to target remote user (#4270) 2016-12-08 11:24:49 -05:00
Thomas Quinot 0bd32c3465 Clarify behaviour when state=present and no name is given (#3904) 2016-12-08 11:24:36 -05:00
Erik Nadel 6f5dfcf1bd Added statement about escaping characters in chron tasks (#3770) 2016-12-08 11:24:32 -05:00
Dmitry Marakasov 13d7a61160 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
2016-12-08 11:24:31 -05:00
Michael Scherer f0fd1109dd Port cron to a py3 and py24 compatible syntax (#3674) 2016-12-08 11:24:28 -05:00
Tobias Wolf 368cf59e4b 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)
2016-12-08 11:24:12 -05:00
Luca Berruti feb309e3cf Typo. 2016-12-08 11:24:04 -05:00
Thomas Quinot ef3308159f 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.
2016-12-08 11:24:00 -05:00
Luca Berruti 0673a4919f cron module: add enviroment variables management 2016-12-08 11:23:59 -05:00
Brian Coca 4c6515e299 reverse order of cron commands
does not affect linux but fixes issue with busybox caring about order
fixes #2807
2016-12-08 11:23:58 -05:00
Jeroen Seegers 7be08b00b0 Update cron.py
Minor update to documentation for the cron module to reflect the required "name" parameter when the value of "state" is "absent".
2016-12-08 11:23:58 -05:00
Achilleas Pipinellis 961082620c Add missing documentation: cron_file requires user to be set 2016-12-08 11:23:40 -05:00
Brian Coca 45907f2ff3 removed typo 2016-12-08 11:23:38 -05:00
Brian Coca d55ba3ab7c removed syslog in favor of common module logging functions 2016-12-08 11:23:38 -05:00
Brian Coca 99159b3cdd changed chmod to 2.4 compat 2016-12-08 11:23:35 -05:00
Evan Kaufman b3495e238c Add disabled option to cron module 2016-12-08 11:23:29 -05:00
Sam Thursfield cad0adc691 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`.
2016-12-08 11:23:28 -05:00
Alexis Seigneurin 53e9caa1d0 - 'name' should not be required so as to allow uninstalling a cron_file 2016-12-08 11:23:13 -05:00
Greg DeKoenigsberg eb881d7d5d Proper author info for all remaining modules 2016-12-08 11:23:07 -05:00
Toshio Kuratomi 84110be91d Update the cron docs to specify that it takes a boolean value 2016-12-08 11:23:00 -05:00
Toshio Kuratomi 623f70ecd6 Fix documentation of the variable that backup file name is returned in 2016-12-08 11:23:00 -05:00
Michael Scherer f7707ea137 Name is a required parameter, fix https://github.com/ansible/ansible/issues/10335 2016-12-08 11:22:55 -05:00
Toshio Kuratomi 7ff9b3990a Update cron example for setting to run twice a day
Fixes #415
2016-12-08 11:22:31 -05:00
Michael DeHaan 213e518165 file extensions! 2016-12-08 11:22:22 -05:00