From f079d022a38f020b985b3e733f443b8ff374c769 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 23 Apr 2014 10:38:38 -0400 Subject: [PATCH 1/3] now when making multiple dirs in path to make dir, same permissions are assigned (but only for NEW dirs) Signed-off-by: Brian Coca --- library/files/file | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/files/file b/library/files/file index 3b4aaa9e235..b10688f2f60 100644 --- a/library/files/file +++ b/library/files/file @@ -165,8 +165,15 @@ def main(): if prev_state == 'absent': if module.check_mode: module.exit_json(changed=True) - os.makedirs(path) changed = True + curpath = '' + for dirname in path.split('/'): + curpath = '/'.join([curpath, dirname]) + if not os.path.exists(curpath): + os.mkdir(curpath) + tmp_file_args = file_args.copy() + tmp_file_args['path']=curpath + changed = module.set_fs_attributes_if_different(tmp_file_args, changed) changed = module.set_fs_attributes_if_different(file_args, changed) From c5d5481ebb9e2a759816cf7a196e6831158adb4b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Sun, 27 Apr 2014 09:37:44 -0400 Subject: [PATCH 2/3] added doc noting the change in behaviour --- lib/ansible/utils/module_docs_fragments/files.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ansible/utils/module_docs_fragments/files.py b/lib/ansible/utils/module_docs_fragments/files.py index 15c6b69bab8..13fe3144d5a 100644 --- a/lib/ansible/utils/module_docs_fragments/files.py +++ b/lib/ansible/utils/module_docs_fragments/files.py @@ -30,14 +30,14 @@ options: state: description: - If C(directory), all immediate subdirectories will be created if they - do not exist. If C(file), the file will NOT be created if it does not - exist, see the M(copy) or M(template) module if you want that behavior. - If C(link), the symbolic link will be created or changed. Use C(hard) - for hardlinks. If C(absent), directories will be recursively deleted, - and files or symlinks will be unlinked. If C(touch) (new in 1.4), an empty file will - be created if the c(path) does not exist, while an existing file or - directory will receive updated file access and modification times (similar - to the way `touch` works from the command line). + do not exist, since 1.6 they will be created with the supplied permissions. + If C(file), the file will NOT be created if it does not exist, see the M(copy) + or M(template) module if you want that behavior. If C(link), the symbolic + link will be created or changed. Use C(hard) for hardlinks. If C(absent), + directories will be recursively deleted, and files or symlinks will be unlinked. + If C(touch) (new in 1.4), an empty file will be created if the c(path) does not + exist, while an existing file or directory will receive updated file access and + modification times (similar to the way `touch` works from the command line). required: false default: file choices: [ file, link, directory, hard, touch, absent ] From 8a84b22d766ea5c9db2865b408de93900fd9c8e1 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 6 May 2014 23:43:07 -0400 Subject: [PATCH 3/3] bumped to 1.7 --- lib/ansible/utils/module_docs_fragments/files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/utils/module_docs_fragments/files.py b/lib/ansible/utils/module_docs_fragments/files.py index 13fe3144d5a..f1b18ba5b0f 100644 --- a/lib/ansible/utils/module_docs_fragments/files.py +++ b/lib/ansible/utils/module_docs_fragments/files.py @@ -30,7 +30,7 @@ options: state: description: - If C(directory), all immediate subdirectories will be created if they - do not exist, since 1.6 they will be created with the supplied permissions. + do not exist, since 1.7 they will be created with the supplied permissions. If C(file), the file will NOT be created if it does not exist, see the M(copy) or M(template) module if you want that behavior. If C(link), the symbolic link will be created or changed. Use C(hard) for hardlinks. If C(absent),