|
|
@ -596,19 +596,19 @@ class AnsibleModule(object):
|
|
|
|
|
|
|
|
|
|
|
|
def atomic_replace(self, src, dest):
|
|
|
|
def atomic_replace(self, src, dest):
|
|
|
|
'''atomically replace dest with src, copying attributes from dest'''
|
|
|
|
'''atomically replace dest with src, copying attributes from dest'''
|
|
|
|
st = os.stat(dest)
|
|
|
|
if os.path.exists(dest):
|
|
|
|
os.chmod(src, st.st_mode & 07777)
|
|
|
|
st = os.stat(dest)
|
|
|
|
try:
|
|
|
|
os.chmod(src, st.st_mode & 07777)
|
|
|
|
os.chown(src, st.st_uid, st.st_gid)
|
|
|
|
try:
|
|
|
|
except OSError, e:
|
|
|
|
os.chown(src, st.st_uid, st.st_gid)
|
|
|
|
if e.errno != errno.EPERM:
|
|
|
|
except OSError, e:
|
|
|
|
raise
|
|
|
|
if e.errno != errno.EPERM:
|
|
|
|
if self.selinux_enabled():
|
|
|
|
raise
|
|
|
|
context = self.selinux_context(dest)
|
|
|
|
if self.selinux_enabled():
|
|
|
|
self.set_context_if_different(src, context, False)
|
|
|
|
context = self.selinux_context(dest)
|
|
|
|
|
|
|
|
self.set_context_if_different(src, context, False)
|
|
|
|
os.rename(src, dest)
|
|
|
|
os.rename(src, dest)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# == END DYNAMICALLY INSERTED CODE ===
|
|
|
|
# == END DYNAMICALLY INSERTED CODE ===
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|