summaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2014-08-21 15:32:51 -0500
committerJames Cammarata <jimi@sngx.net>2014-08-21 15:32:51 -0500
commit005ca0e5ecb2217bbc6be80fa322dbf8a119c505 (patch)
treebd2412624d9c93a7c3afa9613751a7c8fea7f3e8 /files
parent1c3e28767d2c7b3b3478830fe7d489da999b1ecb (diff)
parent97d6807ec569640d8fc64803ca9989b6abfa80d0 (diff)
downloadansible-modules-extras-005ca0e5ecb2217bbc6be80fa322dbf8a119c505.tar.gz
Merge branch 'relative-path-fix' of https://github.com/major/ansible into major-relative-path-fix
Diffstat (limited to 'files')
-rw-r--r--files/file9
1 files changed, 8 insertions, 1 deletions
diff --git a/files/file b/files/file
index 6e663e52..85102cb9 100644
--- a/files/file
+++ b/files/file
@@ -210,8 +210,15 @@ def main():
module.exit_json(changed=True)
changed = True
curpath = ''
- for dirname in path.split('/'):
+ # Split the path so we can apply filesystem attributes recursively
+ # from the root (/) directory for absolute paths or the base path
+ # of a relative path. We can then walk the appropriate directory
+ # path to apply attributes.
+ for dirname in path.strip('/').split('/'):
curpath = '/'.join([curpath, dirname])
+ # Remove leading slash if we're creating a relative path
+ if not os.path.isabs(path):
+ curpath = curpath.lstrip('/')
if not os.path.exists(curpath):
os.mkdir(curpath)
tmp_file_args = file_args.copy()