Open rhughes1 opened 5 years ago
Same problem here! With latest chef-client and motd cookbook. manage_directory
is now useless in our environment. Hopefully somebody is able to fix this bug, soon.
Apologies to @rhughes1 for never replying to the very well reported issue, and sorry that @lehn-etracker also has this problem.
I've attempted to write tests reproducing the issue, but I have not been successful. My work is in branch https://github.com/zts/chef-cookbook-managed_directory/tree/update_tests , which introduce a simple custom resource which uses the file
and directory
resources. Surprisingly, manage_directory
appears to work.
I'm not sure what I'm doing wrong with the tests, as I'm 100% certain that the problem exists. I figured it would be possible to solve this using the event system, and the change in this PR also looks promising.
I don't currently use this cookbook, but if you can give me a failing test then I'll see if I can figure it out.
Description:
I've built out a custom resource which calls the Chef directory and cookbook_file native resources. It correctly lays the cookbook_file in the directory which was created beforehand. In the recipe I then call
managed_directory
with the recursive set to true. It seems as though the managed_directory resource doesn't take into account any file or directory resources created inside custom resourcesExpected Result
The file and directory shouldn't get deleted as they were created by Chef in the custom resource
Actual Result
The file and directory get deleted when the
managed_directory
resource is called.Steps to Reproduce
Create the following
Recipe:
Custom Resource
Kitchen Logs
Platform: CentOS 7.4 Chef Client Version: 14.3.37 Workaround: So it does seem like there's a workaround, but it seems rather inconvenient to do. In the custom resource, change the directory and the cookbook file to this:
This will add the resources to the RunContext, but there must be a way to not only scan the main RunContext but also scan any custom resources which also use recipe DSL?