6

I'm just learning saltstack to start automating provisioning and deployment. One thing I'm having trouble finding is how to recursively set ownership on a directory after extracting an archive. When I use the user and group properties, I get a warning that says this functionality will be dropped in archive.extracted in a future release (carbon).

This seems so trivial, but I can't find a good way to do the equivalent of chown -R user:user on the dir that's extracted from the tar I'm unpacking.

The only thing I could find via googling was to add a cmd.run statement in the state file that runs chown and requires the statement that unpacks the tar. There's gotta be a better way, right?

EDIT: the cmd.run workout works perfectly btw, it just seems like a work around.

bitkot
  • 4,466
  • 2
  • 28
  • 39
user797963
  • 2,907
  • 9
  • 47
  • 88

1 Answers1

10

Here's how I have used it. I extract the file and then have a file.directory which set's the permission.

/path/to/extracted/dir:
  file.directory:
    - user: <someuser>
    - group: <group>
    - mode: 755 # some permission    
    - recurse:
      - user
      - group
    - require:
      - archive: <State id of `archive.extracted`>
bitkot
  • 4,466
  • 2
  • 28
  • 39
  • You probably want a require to the archive.extracted state in there, too. – Andrew Jul 30 '15 at 14:02
  • This works, but not much different than using cmd.run to change ownership. I'm surprised you can't set ownership in the archive.extracted state. – user797963 Jul 30 '15 at 15:01
  • This is probably because salt internally uses os utilities to extract the file and none of the utilities provide a way to set permission while extraction and not all of the utilities provide feature of permission retention, eg. tar does but not zip. – bitkot Jul 31 '15 at 08:37
  • ah, i guess that makes total sense when you put it that way. thanks! – user797963 Aug 03 '15 at 19:08