Skip to content

Instantly share code, notes, and snippets.

@moali87
Created February 9, 2016 16:11
Show Gist options
  • Save moali87/08dbe5f0036ade5bd112 to your computer and use it in GitHub Desktop.
Save moali87/08dbe5f0036ade5bd112 to your computer and use it in GitHub Desktop.
{% for args in pillar.get('service_accounts:teamcity', {}).items() %}
{{ args['user'] }}:
user.present:
- home: {{ args['home'] }}
- shell: {{ args['shell'] }}
- uid: {{ args['uid'] }}
- groups: {{ args['groups'] }}
- fullname: {{ args['fullname'] }}
ssh_auth.present:
- user: {{ args['user'] }}
- source: salt://service_accounts/keys/{{ args['user'] }}.pub
- config: /home/{{ args['user'] }}/.ssh/authorized_keys
{% endfor %}
@moali87
Copy link
Author

moali87 commented Feb 9, 2016

Returns nothing.

ea9e4932940e:

Summary for ea9e4932940e
-----------
Succeeded: 0
Failed:   0
-----------
Total states run:    0
Total run time:  0.000 ms

@moali87
Copy link
Author

moali87 commented Feb 9, 2016

[root@ea9e4932940e sudoers.d]# salt-call state.show_sls service_accounts
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://service_accounts/init.sls'
local:
    ----------
[root@ea9e4932940e sudoers.d]#

@whytewolf
Copy link

{% for account,args in pillar.get('service_accounts', {}).items() %}
{{ args['user'] }}:
  user.present:
    - home: {{ args['home'] }}
    - shell: {{ args['shell'] }}
    - uid: {{ args['uid'] }}
    - groups: {{ args['groups'] }}
    - fullname: {{ args['fullname'] }}
  ssh_auth.present:
    - user: {{ args['user'] }}
    - source: salt://service_accounts/keys/{{ args['user'] }}.pub
    - config: /home/{{ args['user'] }}/.ssh/authorized_keys
{%endfor%}

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