Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change ownership, or chown -R user:user equivalent with saltstack?

Tags:

salt-stack

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.

like image 688
user797963 Avatar asked Jul 30 '15 03:07

user797963


1 Answers

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`>
like image 99
bitkot Avatar answered Oct 20 '22 04:10

bitkot