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
f72649d0
Commit
f72649d0
authored
Apr 16, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2698 from skvidal/atomic_replace_and_cron
Atomic replace and cron
parents
84fb92da
f74a1fa4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
lib/ansible/module_common.py
+5
-1
library/cron
+12
-3
No files found.
lib/ansible/module_common.py
View file @
f72649d0
...
...
@@ -797,7 +797,11 @@ class AnsibleModule(object):
if self.selinux_enabled():
context = self.selinux_default_context(dest)
self.set_context_if_different(src, context, False)
os.rename(src, dest)
try:
shutil.copy2(src, dest)
except shutil.Error, e:
self.fail_json(msg='Could not atomic_replace file:
%
s to
%
s:
%
s'
%
(src, dest, e))
def run_command(self, args, check_rc=False, close_fds=False, executable=None, data=None):
'''
...
...
library/cron
View file @
f72649d0
...
...
@@ -132,6 +132,7 @@ updates: Mike Grozak
import
re
import
tempfile
import
os
def
get_jobs_file
(
module
,
user
,
tmpfile
,
cron_file
):
if
cron_file
:
...
...
@@ -143,11 +144,19 @@ def get_jobs_file(module, user, tmpfile, cron_file):
def
install_jobs
(
module
,
user
,
tmpfile
,
cron_file
):
if
cron_file
:
cmd
=
"ln -f
%
s /etc/cron.d/
%
s"
%
(
tmpfile
,
cron_file
)
cron_file
=
'/etc/cron.d/
%
s'
%
cron_file
try
:
module
.
atomic_replace
(
tmpfile
,
cron_file
)
except
(
OSError
,
IOError
),
e
:
return
(
1
,
""
,
str
(
e
))
except
:
return
(
1
,
""
,
str
(
e
))
else
:
return
(
0
,
""
,
""
)
else
:
cmd
=
"crontab
%
s
%
s"
%
(
user
,
tmpfile
)
return
module
.
run_command
(
cmd
)
return
module
.
run_command
(
cmd
)
def
get_jobs
(
tmpfile
):
lines
=
open
(
tmpfile
)
.
read
()
.
splitlines
()
...
...
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