2014-12-30 23:27:52 +01:00
|
|
|
{%- macro print_name(identifier, key) -%}
|
|
|
|
{%- if 'name' in key %}
|
2015-05-22 14:32:57 +02:00
|
|
|
{{ key['name'] }}
|
2014-12-30 23:27:52 +01:00
|
|
|
{%- else %}
|
2015-05-22 14:32:57 +02:00
|
|
|
{{ identifier }}
|
2014-12-30 23:27:52 +01:00
|
|
|
{%- 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 %}
|
2014-12-30 23:27:52 +01: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.items() -%}
|
|
|
|
{%- for key in keys -%}
|
|
|
|
{% if 'present' in key and key['present'] %}
|
|
|
|
{{ print_name(identifier, key) }}:
|
|
|
|
ssh_auth.present:
|
|
|
|
{{ print_ssh_auth(identifier, key) }}
|
2014-02-09 23:38:30 +01:00
|
|
|
- require:
|
|
|
|
- service: {{ openssh.service }}
|
2014-04-24 00:29:47 +02:00
|
|
|
{%- else %}
|
2014-12-30 23:27:52 +01:00
|
|
|
{{ print_name(identifier, key) }}:
|
2014-02-09 23:38:30 +01:00
|
|
|
ssh_auth.absent:
|
2014-12-30 23:27:52 +01:00
|
|
|
{{ print_ssh_auth(identifier, key) }}
|
2014-04-24 00:29:47 +02:00
|
|
|
{%- endif -%}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- endfor -%}
|