2015-07-13 15:59:44 +02:00
|
|
|
{%- macro print_name(identifier, key) -%}
|
|
|
|
{%- if 'name' in key %}
|
|
|
|
{{ key['name'] }}
|
|
|
|
{%- else %}
|
|
|
|
{{ identifier }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endmacro -%}
|
|
|
|
|
|
|
|
{%- macro print_ssh_auth(identifier, key) -%}
|
|
|
|
{%- if 'user' in key %}
|
|
|
|
- user: {{ key['user'] }}
|
|
|
|
{%- else %}
|
|
|
|
- user: {{ identifier }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'present' in key and key['present'] and 'source' in key %}
|
2014-02-09 23:38:30 +01:00
|
|
|
- source: {{ key['source'] }}
|
2014-04-24 00:29:47 +02:00
|
|
|
{%- else %}
|
|
|
|
{%- if 'enc' in key %}
|
2014-02-09 23:38:30 +01:00
|
|
|
- enc: {{ key['enc'] }}
|
2014-04-24 00:29:47 +02:00
|
|
|
{%- endif -%}
|
|
|
|
{%- if 'comment' in key %}
|
2014-02-09 23:38:30 +01:00
|
|
|
- comment: {{ key['comment'] }}
|
2014-04-24 00:29:47 +02:00
|
|
|
{%- endif -%}
|
|
|
|
{%- if 'options' in key %}
|
2014-02-09 23:38:30 +01:00
|
|
|
- options: {{ key['options'] }}
|
2014-04-24 00:29:47 +02:00
|
|
|
{%- endif -%}
|
|
|
|
{%- endif %}
|
2015-07-13 15:59:44 +02:00
|
|
|
{%- endmacro -%}
|
|
|
|
|
|
|
|
include:
|
|
|
|
- openssh
|
|
|
|
{%- from "openssh/map.jinja" import openssh with context -%}
|
|
|
|
{%- set openssh_pillar = pillar.get('openssh', {}) -%}
|
|
|
|
{%- set auth = openssh_pillar.get('auth', {}) -%}
|
|
|
|
{%- for identifier,keys in auth.iteritems() -%}
|
|
|
|
{%- for key in keys -%}
|
|
|
|
{% if 'present' in key and key['present'] %}
|
|
|
|
{{ print_name(identifier, key) }}:
|
|
|
|
ssh_auth.present:
|
|
|
|
{{ print_ssh_auth(identifier, key) }}
|
2015-11-17 11:09:37 +01:00
|
|
|
- config: {{ pillar['sshd_config']['AuthorizedKeysFile'] }}
|
2014-02-09 23:38:30 +01:00
|
|
|
- require:
|
|
|
|
- service: {{ openssh.service }}
|
2014-04-24 00:29:47 +02:00
|
|
|
{%- else %}
|
2015-07-13 15:59:44 +02:00
|
|
|
{{ print_name(identifier, key) }}:
|
2014-02-09 23:38:30 +01:00
|
|
|
ssh_auth.absent:
|
2015-07-13 15:59:44 +02:00
|
|
|
{{ print_ssh_auth(identifier, key) }}
|
2015-11-17 11:09:37 +01:00
|
|
|
- config: {{ pillar['sshd_config']['AuthorizedKeysFile'] }}
|
2014-04-24 00:29:47 +02:00
|
|
|
{%- endif -%}
|
|
|
|
{%- endfor -%}
|
2015-11-17 11:09:37 +01:00
|
|
|
{%- endfor -%}
|