Skip to content

Instantly share code, notes, and snippets.

Created February 24, 2017 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/cf0090afd32a82854c2c8e14e861cdb9 to your computer and use it in GitHub Desktop.
Save anonymous/cf0090afd32a82854c2c8e14e861cdb9 to your computer and use it in GitHub Desktop.
# pillar data
local_users:
myuser:
youruser:
password: 'hashedpassword'
# state
{% for login, user in pillar.get('local_users', {}).items() %}
{{ login }}:
user.present:
- name: {{ login }}
{% if 'password' in pillar %}
- shell: '/bin/bash'
- password: {{ login.password }}
{% endif %}
{% endfor %}
@gtmanfred
Copy link

gtmanfred commented Feb 24, 2017


# pillar data
local_users:
  myuser:
  youruser:
    password: 'hashedpassword'
    
# state
{%- for login, user in pillar.get('local_users', {}).items() %}
{{ login }}:
  user.present:
    - name: {{ login }}
    {%- if user.password is defined %}
    - shell: '/bin/bash'
    - password: {{ user.password }}
    {%- endif %}
{%- endfor %}

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