salt icon indicating copy to clipboard operation
salt copied to clipboard

file.recurse doesn't support multiple sources like file.managed does

Open localfilmmaker opened this issue 12 years ago • 13 comments

I expect file.recurse to behave the same as file.managed when providing a source. Meaning that you could provide a list of sources and it would use the first one that exists. However, file.recurse doesn't do this; it only takes one source value.

I'd like to do something like this:

/etc/skel:
  file.recurse:
    - user: root
    - group: root
    - source:
      - salt://packages/core/files/skel.{{ grains['host'] }}
      - salt://packages/core/files/skel.{{ grains['server_role'] }}
      - salt://packages/core/files/skel

Thus having different files and subdirectories for /etc/skel/ for different hosts. Currently it doesn't work this way and I don't know of any alternate way to do it.

localfilmmaker avatar Dec 17 '13 00:12 localfilmmaker

Thanks for the request! This is doable, we just need to add the same multi-source logic to file.recurse that's currently in file.managed.

basepi avatar Dec 17 '13 21:12 basepi

I join this request!

fxsever avatar Jan 16 '14 14:01 fxsever

+1!

feigner avatar Feb 19 '14 06:02 feigner

+1

fenderle avatar Jun 18 '14 08:06 fenderle

+1

vijay-santhosh avatar Jul 23 '14 13:07 vijay-santhosh

+1

yermulnik avatar Jul 08 '15 08:07 yermulnik

Actually it already does exactly this, at least in 2015.5. I came here (@yermulnik, you did too?) because I would actually really like for file.recurse to take all sources when I so desire (which I obviously do in this case).

Would something like all_sources=False be a nice option for this?

The-Loeki avatar Aug 04 '15 11:08 The-Loeki

@The-Loeki, on my side (salt 2015.5.2 (Lithium)) the problem is exactly as described by topicstarter.

yermulnik avatar Aug 04 '15 12:08 yermulnik

@yermulnik héhéhé that's entirely possible in retrospect; looking at the commit history of /salt/states/file.py it seems to be backported real recently (May; ac29c0cdd077a8bcfcb763b4c830d8ebf0e123f4 (?) )

The-Loeki avatar Aug 04 '15 12:08 The-Loeki

But it hasn't been committed into a release yet?

yermulnik avatar Aug 04 '15 13:08 yermulnik

not sure; that particular commit ought to be in 2015.5.2, all I can tell you is that seems to be working here under 2015.5 git under CentOS 7.1

The-Loeki avatar Aug 04 '15 14:08 The-Loeki

Awesome, thanks for tracking down that commit, @The-Loeki! It appears to be in 2015.5.2 and will be in 2015.8.0 as well when it's released.

basepi avatar Aug 04 '15 17:08 basepi

Gah, I didn't read closely enough. The commit does appear to be in 2015.5.2, if I'm reading the github summary correctly. It is definitely in 2015.8.0 release candidates.

basepi avatar Aug 04 '15 17:08 basepi