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
890202e4
Commit
890202e4
authored
Feb 28, 2014
by
Richard C Isaacson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy module: cleanup and if directory_mode not set default to umask
parent
cf4a6b39
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
+14
-1
library/files/copy
+14
-1
No files found.
library/files/copy
View file @
890202e4
...
@@ -103,7 +103,12 @@ EXAMPLES = '''
...
@@ -103,7 +103,12 @@ EXAMPLES = '''
- copy: src=/mine/sudoers dest=/etc/sudoers validate='visudo -cf
%
s'
- copy: src=/mine/sudoers dest=/etc/sudoers validate='visudo -cf
%
s'
'''
'''
def
split_pre_existing_dir
(
dirname
):
def
split_pre_existing_dir
(
dirname
):
'''
Return the first pre-existing directory and a list of the new directories that will be created.
'''
head
,
tail
=
os
.
path
.
split
(
dirname
)
head
,
tail
=
os
.
path
.
split
(
dirname
)
if
not
os
.
path
.
exists
(
head
):
if
not
os
.
path
.
exists
(
head
):
(
pre_existing_dir
,
new_directory_list
)
=
split_pre_existing_dir
(
head
)
(
pre_existing_dir
,
new_directory_list
)
=
split_pre_existing_dir
(
head
)
...
@@ -112,7 +117,12 @@ def split_pre_existing_dir(dirname):
...
@@ -112,7 +117,12 @@ def split_pre_existing_dir(dirname):
new_directory_list
.
insert
(
0
,
tail
)
new_directory_list
.
insert
(
0
,
tail
)
return
(
pre_existing_dir
,
new_directory_list
)
return
(
pre_existing_dir
,
new_directory_list
)
def
adjust_recursive_directory_permissions
(
pre_existing_dir
,
new_directory_list
,
module
,
directory_args
,
changed
):
def
adjust_recursive_directory_permissions
(
pre_existing_dir
,
new_directory_list
,
module
,
directory_args
,
changed
):
'''
Walk the new directories list and make sure that permissions are as we would expect
'''
if
len
(
new_directory_list
)
>
0
:
if
len
(
new_directory_list
)
>
0
:
working_dir
=
os
.
path
.
join
(
pre_existing_dir
,
new_directory_list
.
pop
(
0
))
working_dir
=
os
.
path
.
join
(
pre_existing_dir
,
new_directory_list
.
pop
(
0
))
directory_args
[
'path'
]
=
working_dir
directory_args
[
'path'
]
=
working_dir
...
@@ -120,6 +130,7 @@ def adjust_recursive_directory_permissions(pre_existing_dir, new_directory_list,
...
@@ -120,6 +130,7 @@ def adjust_recursive_directory_permissions(pre_existing_dir, new_directory_list,
changed
=
adjust_recursive_directory_permissions
(
working_dir
,
new_directory_list
,
module
,
directory_args
,
changed
)
changed
=
adjust_recursive_directory_permissions
(
working_dir
,
new_directory_list
,
module
,
directory_args
,
changed
)
return
changed
return
changed
def
main
():
def
main
():
module
=
AnsibleModule
(
module
=
AnsibleModule
(
...
@@ -132,7 +143,7 @@ def main():
...
@@ -132,7 +143,7 @@ def main():
backup
=
dict
(
default
=
False
,
type
=
'bool'
),
backup
=
dict
(
default
=
False
,
type
=
'bool'
),
force
=
dict
(
default
=
True
,
aliases
=
[
'thirsty'
],
type
=
'bool'
),
force
=
dict
(
default
=
True
,
aliases
=
[
'thirsty'
],
type
=
'bool'
),
validate
=
dict
(
required
=
False
,
type
=
'str'
),
validate
=
dict
(
required
=
False
,
type
=
'str'
),
directory_mode
=
dict
(
required
=
False
)
directory_mode
=
dict
(
required
=
False
)
),
),
add_file_common_args
=
True
,
add_file_common_args
=
True
,
)
)
...
@@ -165,6 +176,8 @@ def main():
...
@@ -165,6 +176,8 @@ def main():
directory_mode
=
module
.
params
[
"directory_mode"
]
directory_mode
=
module
.
params
[
"directory_mode"
]
if
directory_mode
is
not
None
:
if
directory_mode
is
not
None
:
directory_args
[
'mode'
]
=
directory_mode
directory_args
[
'mode'
]
=
directory_mode
else
:
directory_args
[
'mode'
]
=
None
adjust_recursive_directory_permissions
(
pre_existing_dir
,
new_directory_list
,
module
,
directory_args
,
changed
)
adjust_recursive_directory_permissions
(
pre_existing_dir
,
new_directory_list
,
module
,
directory_args
,
changed
)
if
os
.
path
.
exists
(
dest
):
if
os
.
path
.
exists
(
dest
):
...
...
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