Rework ssh_keys_pillar-related states
SSH key pairs deployed via the user's ssh_keys_pillar dict aren't handled the same as the user's ssh_keys, e.g., file ownership and permissions aren't specified, and the keying material gets copied directly into the SLS file. This change rewrites the two templated file.managed states to behave as follows: - set the files' owner to be the user - set the files' group to be the user's primary group - for the public key, set the mode to 644 (u=rw,go=r) - for the private key, set the mode to 600 (u=rw,g=) - pull the files' contents directly from pillar
This commit is contained in:
parent
001e913e77
commit
2f4c088e5d
|
@ -174,19 +174,33 @@ users_ssh_auth_{{ name }}_{{ loop.index0 }}:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if 'ssh_keys_pillar' in user %}
|
{% if 'ssh_keys_pillar' in user %}
|
||||||
{% for key_name, pillar_name in user['ssh_keys_pillar'].iteritems() %}
|
{% for key_name, pillar_name in user['ssh_keys_pillar'].items() %}
|
||||||
users_ssh_keys_files_{{ name }}_{{ key_name }}_pub:
|
user_ssh_keys_files_{{ name }}_{{ key_name }}_private_key:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: {{ user.get('home', '/home/{0}'.format(name)) }}/.ssh/{{ key_name
|
- name: {{ user.get('home', '/home/{0}'.format(name)) }}/.ssh/{{ key_name }}
|
||||||
}}.pub
|
- user: {{ name }}
|
||||||
- contents: |
|
- group: {{ user_group }}
|
||||||
{{ pillar[pillar_name][key_name]['pubkey'] }}
|
- mode: 600
|
||||||
users_ssh_keys_files_{{ name }}_{{ key_name }}_priv:
|
- show_diff: False
|
||||||
|
- contents_pillar: {{ pillar_name }}:{{ key_name }}:privkey
|
||||||
|
- require:
|
||||||
|
- user: users_{{ name }}_user
|
||||||
|
{% for group in user.get('groups', []) %}
|
||||||
|
- group: users_{{ name }}_{{ group }}_group
|
||||||
|
{% endfor %}
|
||||||
|
user_ssh_keys_files_{{ name }}_{{ key_name }}_public_key:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: {{ user.get('home', '/home/{0}'.format(name)) }}/.ssh/{{ key_name
|
- name: {{ user.get('home', '/home/{0}'.format(name)) }}/.ssh/{{ key_name }}.pub
|
||||||
}}
|
- user: {{ name }}
|
||||||
- contents: |
|
- group: {{ user_group }}
|
||||||
{{ pillar[pillar_name][key_name]['privkey'] | indent(8) }}
|
- mode: 644
|
||||||
|
- show_diff: False
|
||||||
|
- contents_pillar: {{ pillar_name }}:{{ key_name }}:pubkey
|
||||||
|
- require:
|
||||||
|
- user: users_{{ name }}_user
|
||||||
|
{% for group in user.get('groups', []) %}
|
||||||
|
- group: users_{{ name }}_{{ group }}_group
|
||||||
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue