redo users and ssh
This commit is contained in:
46
ssh/init.sls
Normal file
46
ssh/init.sls
Normal file
@@ -0,0 +1,46 @@
|
||||
{% from "ssh/map.jinja" import ssh_users with context %}
|
||||
|
||||
{% for user, confs in ssh_users.items() %}
|
||||
{% set homedir = salt.user.info(user).get('home', None) %}
|
||||
{% if homedir is none %}
|
||||
|
||||
{{ "~%s/.ssh" | format(user) }}:
|
||||
test.fail_without_changes:
|
||||
- name: {{ "No homedir for %s - if they were created in this run, run this state again" | format(user) }}
|
||||
|
||||
{% else %}
|
||||
|
||||
{{ homedir }}/.ssh:
|
||||
file.directory:
|
||||
- user: {{ user }}
|
||||
- group: {{ user }}
|
||||
- mode: 700
|
||||
{% if 'authorized_keys' in confs %}
|
||||
{{ homedir }}/.ssh/authorized_keys:
|
||||
file.managed:
|
||||
- template: jinja
|
||||
- source: salt://ssh/files/authorized_keys.jinja
|
||||
- user: {{ user }}
|
||||
- group: {{ user }}
|
||||
- mode: 400
|
||||
- context:
|
||||
user: {{ user }}
|
||||
- require:
|
||||
- file: {{ homedir }}/.ssh
|
||||
{% endif %}
|
||||
{% if 'ssh_hosts' in confs %}
|
||||
{{ homedir }}/.ssh/config:
|
||||
file.managed:
|
||||
- source: 'salt://ssh/files/ssh_hosts.jinja'
|
||||
- template: jinja
|
||||
- user: {{ user }}
|
||||
- group: {{ user }}
|
||||
- mode: 0400
|
||||
- context:
|
||||
user: {{ user }}
|
||||
- require:
|
||||
- file: {{ homedir }}/.ssh
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user