Skip to content

Instantly share code, notes, and snippets.

@moali87
Created November 3, 2016 17:56
Show Gist options
  • Save moali87/8c5a67a1556aeccbf85702e6ce5dc736 to your computer and use it in GitHub Desktop.
Save moali87/8c5a67a1556aeccbf85702e6ce5dc736 to your computer and use it in GitHub Desktop.
$users = ['david.gonzales', 'akhter.ali', 'sierah.nguon']
$users.each |String $users| {
user { $users:
ensure => 'present',
gid => '500',
password_hash => '!!',
uid => '500',
shell => '/bin/bash'}
}
@moali87
Copy link
Author

moali87 commented Nov 3, 2016

Salt

Pillars
users:
akhter.ali:
uid: 500
gid: 500
shell: /bin/bash
password_hash: !!
david.gonzales:
uid: 501
gid: 501
shell: /bin/bash
password_hash: !!

Example state:
#!py

config = {}
def run():
for user, data in salt'pillar.get'.iteritems:
config['user_{0}.format(user)] = {
'user.present': [
{'name': user},
{'uid': data['uid']},
{'gid': data['gid']},
{'shell': data['shell']},
{'password_hash': data['password_hash']}
]
}

Example state2:
{% for user, data in salt'pillar.get'.iteritems %}
user_{{ user }}:
user.present:
name: {{ user }}
uid: {{ data['uid'] }}
gid: {{ data['gid'] }}
shell: {{ data['shell'] }}
password_hash: {{ data['password_hash'] }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment