Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
6fc6c374
Commit
6fc6c374
authored
Dec 19, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1785 from TutoringAustralasia/devel
Add support for @reboot to cron module
parents
97cc384c
96e2805b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
library/cron
+23
-2
No files found.
library/cron
View file @
6fc6c374
...
...
@@ -98,11 +98,22 @@ options:
required: false
default: "*"
aliases: []
reboot:
description:
- If the job should be run at reboot, will ignore minute, hour, day, and month settings in favour of @reboot
required: false
default: False
aliases: []
examples:
- code: 'cron: name="check dirs" hour="5,2" job="ls -alh > /dev/null"'
description: Ensure a job that runs at 2 and 5 exists. Creates an entry like "* 5,2 * * ls -alh > /dev/null"
- code: 'cron: name="an old job" cron job="/some/dir/job.sh" state=absent'
description: 'Ensure an old job is no longer present. Removes any job that is preceded by "#Ansible: an old job" in the crontab'
- code: 'cron: name="a job for reboot" reboot=True job="/some/job.sh"'
description: 'Creates an entry like '@reboot /some/job.sh'
requirements: cron
author: Dane Summers
'''
...
...
@@ -221,7 +232,8 @@ def main():
hour
=
dict
(
default
=
'*'
),
day
=
dict
(
default
=
'*'
),
month
=
dict
(
default
=
'*'
),
weekday
=
dict
(
default
=
'*'
)
weekday
=
dict
(
default
=
'*'
),
reboot
=
dict
(
required
=
False
,
default
=
False
,
choices
=
BOOLEANS
)
)
)
...
...
@@ -234,9 +246,17 @@ def main():
day
=
module
.
params
[
'day'
]
month
=
module
.
params
[
'month'
]
weekday
=
module
.
params
[
'weekday'
]
reboot
=
module
.
boolean
(
module
.
params
.
get
(
'reboot'
,
False
))
do_install
=
module
.
params
[
'state'
]
==
'present'
changed
=
False
job
=
"
%
s
%
s
%
s
%
s
%
s
%
s"
%
(
minute
,
hour
,
day
,
month
,
weekday
,
job
)
if
reboot
and
(
True
in
[(
x
!=
'*'
)
for
x
in
[
minute
,
hour
,
day
,
month
,
weekday
]]):
module
.
fail_json
(
msg
=
"You must specify either reboot=True or any of minute, hour, day, month, weekday"
)
if
reboot
:
job
=
"@reboot
%
s"
%
(
job
)
else
:
job
=
"
%
s
%
s
%
s
%
s
%
s
%
s"
%
(
minute
,
hour
,
day
,
month
,
weekday
,
job
)
if
not
user
:
user
=
""
...
...
@@ -288,3 +308,4 @@ def main():
# include magic from lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment