Created
November 7, 2013 12:10
-
-
Save viq/7353629 to your computer and use it in GitHub Desktop.
It creates the groups properly, but does not assign users to them.
This file contains hidden or 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
{% from "users/map.jinja" import users with context %} | |
group1: | |
mbarnett: | |
fullname: Melissa Barnett | |
home: /home/mbarnett |
This file contains hidden or 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
{% from "users/map.jinja" import users with context %} | |
group3: | |
ehunter: | |
fullname: Ethan Hunter | |
home: /home/ehunter |
This file contains hidden or 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
groups: | |
{% if grains['os'] == 'OpenBSD' %} | |
group1: | |
- wheel | |
group3: | |
- 3group | |
{% elif grains['os'] == 'Debian' %} | |
group1: | |
- 1group | |
group3: | |
- sudo | |
{% endif %} |
This file contains hidden or 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
{% set users = salt['grains.filter_by']({ | |
'Debian': { | |
'adm_group': 'sudo', | |
}, | |
'OpenBSD': { | |
'adm_group': 'wheel', | |
}, | |
}, merge=salt['pillar.get']('users.lookup')) %} |
This file contains hidden or 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
{% for user, args in pillar['group1'].iteritems() %} | |
{{ user }}: | |
# group: | |
# - present | |
user.present: | |
- home: {{ args['home'] }} | |
{% if 'password' in args %} | |
- password: {{ args['password'] }} | |
{% if 'enforce_password' in args %} | |
- enforce_password: {{ args['enforce_password'] }} | |
{% endif %} | |
{% endif %} | |
- fullname: {{ args['fullname'] }} | |
- groups: {{ salt['pillar.get']('groups:group1') }} | |
# - require: | |
# - group: {{ user }} | |
{% if 'key.pub' in args and args['key.pub'] == True %} | |
{{ user }}_key.pub: | |
ssh_auth: | |
- present | |
- user: {{ user }} | |
- source: salt://users/{{ user }}/keys/key.pub | |
{% endif %} | |
{% endfor %} |
This file contains hidden or 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
{% for user, args in pillar['group3'].iteritems() %} | |
{{ user }}: | |
# group: | |
# - present | |
user.present: | |
- home: {{ args['home'] }} | |
{% if 'password' in args %} | |
- password: {{ args['password'] }} | |
{% if 'enforce_password' in args %} | |
- enforce_password: {{ args['enforce_password'] }} | |
{% endif %} | |
{% endif %} | |
- fullname: {{ args['fullname'] }} | |
- groups: {{ salt['pillar.get']('groups:group3') }} | |
# - require: | |
# - group: {{ user }} | |
{% if 'key.pub' in args and args['key.pub'] == True %} | |
{{ user }}_key.pub: | |
ssh_auth: | |
- present | |
- user: {{ user }} | |
- source: salt://users/{{ user }}/keys/key.pub | |
{% endif %} | |
{% endfor %} |
This file contains hidden or 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
{% for group, args in pillar['groups'].iteritems() %} | |
{{ args.pop() }}: | |
group: | |
- present | |
{% endfor %} |
This file contains hidden or 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
include: | |
- users.groups | |
- users.group1 | |
- users.group3 |
This file contains hidden or 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
# salt obsd1 state.show_sls users | |
obsd1: | |
---------- | |
3group: | |
---------- | |
__env__: | |
base | |
__sls__: | |
users.groups | |
group: | |
- present | |
---------- | |
- order: | |
10001 | |
ehunter: | |
---------- | |
__env__: | |
base | |
__sls__: | |
users.group3 | |
user: | |
---------- | |
- home: | |
/home/ehunter | |
---------- | |
- fullname: | |
Ethan Hunter | |
---------- | |
- groups: | |
- present | |
---------- | |
- order: | |
10003 | |
mbarnett: | |
---------- | |
__env__: | |
base | |
__sls__: | |
users.group1 | |
user: | |
---------- | |
- home: | |
/home/mbarnett | |
---------- | |
- fullname: | |
Melissa Barnett | |
---------- | |
- groups: | |
- present | |
---------- | |
- order: | |
10002 | |
wheel: | |
---------- | |
__env__: | |
base | |
__sls__: | |
users.groups | |
group: | |
- present | |
---------- | |
- order: | |
10000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment