From 76cec9d360454b4376e46b931f0f7f6cd9e13e25 Mon Sep 17 00:00:00 2001 From: Julian Yap Date: Fri, 11 Oct 2013 15:56:14 -1000 Subject: [PATCH] Assume state='directory' if recurse is set and previous state was 'directory' Resolves this issue: https://github.com/ansible/ansible/issues/2067 --- library/files/file | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/files/file b/library/files/file index 28a0ce50be..adbc21061a 100644 --- a/library/files/file +++ b/library/files/file @@ -200,9 +200,14 @@ def main(): elif os.stat(path).st_nlink > 1: prev_state = 'hard' else: - # could be many other tings, but defaulting to file + # could be many other things, but defaulting to file prev_state = 'file' + recurse = params['recurse'] + + if recurse and state == 'file' and prev_state == 'directory': + state = 'directory' + if prev_state != 'absent' and state == 'absent': try: if prev_state == 'directory': @@ -248,7 +253,6 @@ def main(): changed = True changed = module.set_directory_attributes_if_different(file_args, changed) - recurse = params['recurse'] if recurse: for root,dirs,files in os.walk( file_args['path'] ): for dir in dirs: