Remove duplicated pillar.get calls to retrieve the sshd_config and ssh_config pillars

This commit is contained in:
Meng Chen authored and alxwr committed 2019-05-25 01:52:33 +02:00
1 parent 463ad69d92
commit 3e01ad816a
4 files changed
+14 -16

No files matched your search

+6 -7
View File
@@ -29,17 +29,16 @@
include:
- openssh
{%- from "openssh/map.jinja" import openssh with context -%}
{%- set openssh_pillar = pillar.get('openssh', {}) -%}
{%- set auth = openssh_pillar.get('auth', {}) -%}
{%- from "openssh/map.jinja" import openssh, sshd_config with context -%}
{%- set auth = openssh.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) }}
{%- if 'sshd_config' in pillar and 'AuthorizedKeysFile' in pillar['sshd_config'] %}
- config: '{{ pillar['sshd_config']['AuthorizedKeysFile'] }}'
{%- if sshd_config.get("AuthorizedKeysFile", None) %}
- config: '{{ sshd_config['AuthorizedKeysFile'] }}'
{% endif %}
- require:
- service: {{ openssh.service }}
@@ -47,8 +46,8 @@ include:
{{ print_name(identifier, key) }}:
ssh_auth.absent:
{{ print_ssh_auth(identifier, key) }}
{%- if 'sshd_config' in pillar and 'AuthorizedKeysFile' in pillar['sshd_config'] %}
- config: '{{ pillar['sshd_config']['AuthorizedKeysFile'] }}'
{%- if sshd_config.get("AuthorizedKeysFile", None) %}
- config: '{{ sshd_config['AuthorizedKeysFile'] }}'
{% endif -%}
{%- endif -%}
{%- endfor -%}