salt icon indicating copy to clipboard operation
salt copied to clipboard

state file.recurse does not copy empty directories

Open sharpone74 opened this issue 14 years ago • 5 comments

Version: 0.9.9.1 OS: ubuntu 12.04

Problem: When attempting to utilize the file.recurse state to recursively install/control a directory on the minions, it is ignoring any directories which have no files in them. Adding any file, even empty files, to a subdirectory causes the entire structure above the file to appear on the next highstate run.

Steps to reproduce:

  1. Create a module 'testdir' with contents as follows, and cause it to be applied to a minion: testdir/init.sls - /tmp/skel: file.recurse:
    • source: salt://testdir/skel mkdir -p skel/a/b/c/d mkdir -p skel/b/c/d mkdir -p skel/c/d touch skel/c/d/empty

highstate output:

State: - file
Name:      /tmp/skel1
Function:  recurse
    Result:    True
    Comment:   
    Changes:   /tmp/skel1/c/d/empty: new
  1. on the minion ls -R /tmp/skel: root@dev-stage01:/tmp# ls -R skel/ skel/: c

skel/c: d

skel/c/d: empty

Notice the other directories (a,b and their subdirs are missing) I looked through the code for about 40 minutes to see if it was an easy fix, but was not able to easily identify. Note that it appears the cached version on the master is also missing the empty subdirs, so it must be in the process of generating the file cache on the master - I am not sure where this happens in code so my digging in the code stopped about there.

sharpone74 avatar May 26 '12 04:05 sharpone74

Disregard my comment about cached version on master, I was misinterpreting what was in /var/cache/salt/files - it turns out my master was also a minion I tested the bug with.

sharpone74 avatar May 26 '12 04:05 sharpone74

Yes, only files are tracked. we can modify the function in the file server to list directories as well as files if a given argument is passed, and then make the directories on the minion. Granted I will need to take a look at a few things to make sure

thatch45 avatar May 26 '12 05:05 thatch45

Yes I think that would be a nice option. For now I can work around it by creating each directory in the state file. It just didn't behave as I would've expected, hence the bug report. I tried last night to add some code to make it work, but python is new to me and I was not yet successful. I may try again today because sometimes I just latch on and can't let things go :-) On May 25, 2012 11:33 PM, "Thomas S Hatch" < [email protected]> wrote:

Yes, only files are tracked. we can modify the function in the file server to list directories as well as files if a given argument is passed, and then make the directories on the minion. Granted I will need to take a look at a few things to make sure


Reply to this email directly or view it on GitHub: https://github.com/saltstack/salt/issues/1344#issuecomment-5944715

sharpone74 avatar May 26 '12 15:05 sharpone74

Awesome, I will be in and out today, but comment if you need help!

thatch45 avatar May 26 '12 15:05 thatch45

This has been fixed in c06f8fd92372bc5720c37d977cc905af70a0e47e

thatch45 avatar Jul 18 '12 17:07 thatch45