2017-03-03 14:17:41 +01:00
|
|
|
include:
|
|
|
|
- openssh
|
|
|
|
|
2020-07-31 10:54:40 +02:00
|
|
|
{% from "openssh/map.jinja" import mapdata with context -%}
|
|
|
|
{%- set openssh = mapdata.openssh %}
|
|
|
|
{%- set sshd_config = mapdata.sshd_config %}
|
2019-04-28 05:00:57 +02:00
|
|
|
{%- set authorized_keys_file = sshd_config.get("AuthorizedKeysFile", None) %}
|
2017-03-03 14:17:41 +01:00
|
|
|
|
2019-04-28 05:00:57 +02:00
|
|
|
{%- for store, config in openssh.get("auth_map", {}).items() %}
|
2017-03-03 14:17:41 +01:00
|
|
|
{%- set store_base = config["source"] %}
|
|
|
|
# SSH store openssh:auth_map:{{ store }}
|
2018-03-10 16:35:57 +01:00
|
|
|
{%- for user, keys in config.get("users", {}).items() %}
|
|
|
|
{%- for key, key_cfg in keys.items() %}
|
2017-03-03 14:17:41 +01:00
|
|
|
"ssh_auth--{{ store }}--{{ user }}--{{ key }}":
|
|
|
|
{%- set present = key_cfg.get("present", True) %}
|
|
|
|
{%- set options = key_cfg.get("options", []) %}
|
|
|
|
{%- if present %}
|
|
|
|
ssh_auth.present:
|
|
|
|
- require:
|
|
|
|
- service: {{ openssh.service }}
|
|
|
|
{%- else %}
|
|
|
|
ssh_auth.absent:
|
|
|
|
{%- endif %}
|
|
|
|
- user: {{ user }}
|
|
|
|
- source: {{ store_base }}/{{ key }}.pub
|
|
|
|
{%- if authorized_keys_file %}
|
|
|
|
- config: "{{ authorized_keys_file }}"
|
|
|
|
{%- endif %}
|
|
|
|
{%- if options %}
|
|
|
|
- options: "{{ options }}"
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endfor %}
|