Skip to content

Commit 3e01ad8

Browse files
chenmenalxwr
authored andcommitted
Remove duplicated pillar.get calls to retrieve the sshd_config and ssh_config pillars
1 parent 463ad69 commit 3e01ad8

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

openssh/auth.sls

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,25 @@
2929

3030
include:
3131
- openssh
32-
{%- from "openssh/map.jinja" import openssh with context -%}
33-
{%- set openssh_pillar = pillar.get('openssh', {}) -%}
34-
{%- set auth = openssh_pillar.get('auth', {}) -%}
32+
{%- from "openssh/map.jinja" import openssh, sshd_config with context -%}
33+
{%- set auth = openssh.get('auth', {}) -%}
3534
{%- for identifier,keys in auth.items() -%}
3635
{%- for key in keys -%}
3736
{% if 'present' in key and key['present'] %}
3837
{{ print_name(identifier, key) }}:
3938
ssh_auth.present:
4039
{{ print_ssh_auth(identifier, key) }}
41-
{%- if 'sshd_config' in pillar and 'AuthorizedKeysFile' in pillar['sshd_config'] %}
42-
- config: '{{ pillar['sshd_config']['AuthorizedKeysFile'] }}'
40+
{%- if sshd_config.get("AuthorizedKeysFile", None) %}
41+
- config: '{{ sshd_config['AuthorizedKeysFile'] }}'
4342
{% endif %}
4443
- require:
4544
- service: {{ openssh.service }}
4645
{%- else %}
4746
{{ print_name(identifier, key) }}:
4847
ssh_auth.absent:
4948
{{ print_ssh_auth(identifier, key) }}
50-
{%- if 'sshd_config' in pillar and 'AuthorizedKeysFile' in pillar['sshd_config'] %}
51-
- config: '{{ pillar['sshd_config']['AuthorizedKeysFile'] }}'
49+
{%- if sshd_config.get("AuthorizedKeysFile", None) %}
50+
- config: '{{ sshd_config['AuthorizedKeysFile'] }}'
5251
{% endif -%}
5352
{%- endif -%}
5453
{%- endfor -%}

openssh/auth_map.sls

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
include:
22
- openssh
33

4-
{% from "openssh/map.jinja" import openssh with context -%}
5-
{%- set openssh_pillar = salt["pillar.get"]("openssh", {}) -%}
6-
{%- set authorized_keys_file = salt["pillar.get"]("sshd_config:AuthorizedKeysFile", None) %}
4+
{% from "openssh/map.jinja" import openssh, sshd_config with context -%}
5+
{%- set authorized_keys_file = sshd_config.get("AuthorizedKeysFile", None) %}
76
8-
{%- for store, config in salt["pillar.get"]("openssh:auth_map", {}).items() %}
7+
{%- for store, config in openssh.get("auth_map", {}).items() %}
98
{%- set store_base = config["source"] %}
109
# SSH store openssh:auth_map:{{ store }}
1110
{%- for user, keys in config.get("users", {}).items() %}

openssh/config_ini.sls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
{% from "openssh/map.jinja" import openssh with context %}
1+
{% from "openssh/map.jinja" import openssh, sshd_config with context %}
22
33
include:
44
- openssh
55
6-
{% if salt['pillar.get']('sshd_config', False) %}
6+
{% if sshd_config %}
77
sshd_config-with-ini:
88
ini.options_present:
99
- name: {{ openssh.sshd_config }}
1010
- separator: ' '
1111
- watch_in:
1212
- service: {{ openssh.service }}
1313
- sections:
14-
{%- for k,v in salt['pillar.get']('sshd_config',{}).items() %}
14+
{%- for k,v in sshd_config.items() %}
1515
{{ k }}: '{{ v }}'
1616
{%- endfor %}
1717
{% endif %}

openssh/files/ssh_config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{%- import_yaml "openssh/defaults.yaml" as default_settings -%}
2-
{%- set ssh_config = salt['pillar.get']('ssh_config', default=default_settings.default.ssh_config, merge=True) -%}
1+
{% from "openssh/map.jinja" import ssh_config with context %}
2+
33
{#- present in ssh_config and known in actual file options -#}
44
{%- set processed_options = [] -%}
55
{%- set string_or_list_options = ['KexAlgorithms', 'Ciphers', 'MACs'] -%}

0 commit comments

Comments
 (0)