Last active
May 16, 2017 14:18
-
-
Save laidback/1331532e5fb94ae7de2a21574a01e9ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# users-formula/basic.sls | |
basic-user: | |
user.present: | |
- name: {{ name }} | |
- gid: {{ gid }} | |
############################ | |
# state tree: vhost-user.sls | |
include: | |
- users.basic.sls | |
# now i want to specify basic user further to become a vhost | |
extend: | |
basic-user: | |
user.present: | |
- home: /var/www/{{ name }} | |
... | |
/var/www/{{ name }}: | |
file.directory: | |
- user: root | |
- group: root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As an aside, on line 11 you just need to write
users.basic
. The.sls
part of the filename isn't included in the SLS ID.I really think that you're better off moving the user account settings into a dictionary in Pillar. This is how I do it:
https://github.com/irtnog/salt-pillar-example/blob/master/defaults/accounts.sls
You could define the user account in a "default" Pillar similar to the above, and then either use a templating command or another Pillar SLS to modify the defaults. Here's how Pillar flattens and merges values:
https://docs.saltstack.com/en/latest/topics/pillar/#pillar-namespace-flattening
https://docs.saltstack.com/en/latest/topics/pillar/#pillar-dictionary-merging
For example, you might have the following in
pillar/defaults.sls
:And then this in
pillar/www/example/com/init.sls
:And this in
pillar/top.sls
:So then your states would look something like this. First,
states/users.sls
:Finally, you'd assign the users SLS to all minions as usual, in
states/top.sls
: