2019-06-23 14:33:54 +02:00
|
|
|
{%- from "openssh/map.jinja" import openssh, sshd_config with context %}
|
2018-02-15 17:43:13 +01:00
|
|
|
|
|
|
|
include:
|
|
|
|
- openssh
|
|
|
|
|
2019-06-23 14:33:54 +02:00
|
|
|
{%- if sshd_config %}
|
2018-02-15 17:43:13 +01:00
|
|
|
sshd_config-with-ini:
|
2019-06-23 14:33:54 +02:00
|
|
|
{#- Convert any tabs to a single space to prevent false positives #}
|
|
|
|
{#- Ref: https://github.com/saltstack-formulas/openssh-formula/issues/162 #}
|
|
|
|
{%- set regex_search_for_tabs = '^(\w+)\t+(\w)' %}
|
|
|
|
{%- if salt['file.contains_regex'](openssh.sshd_config, regex_search_for_tabs) %}
|
|
|
|
file.replace:
|
|
|
|
- name: {{ openssh.sshd_config }}
|
|
|
|
- pattern: {{ regex_search_for_tabs }}
|
|
|
|
- repl: '\1 \2'
|
|
|
|
- show_changes: True
|
|
|
|
- require_in:
|
2020-06-04 18:58:24 +02:00
|
|
|
- ini: sshd_config-with-ini
|
2019-06-23 14:33:54 +02:00
|
|
|
{%- endif %}
|
|
|
|
|
2018-02-15 17:43:13 +01:00
|
|
|
ini.options_present:
|
|
|
|
- name: {{ openssh.sshd_config }}
|
|
|
|
- separator: ' '
|
|
|
|
- watch_in:
|
|
|
|
- service: {{ openssh.service }}
|
|
|
|
- sections:
|
2019-04-28 05:00:57 +02:00
|
|
|
{%- for k,v in sshd_config.items() %}
|
2018-02-15 17:43:13 +01:00
|
|
|
{{ k }}: '{{ v }}'
|
|
|
|
{%- endfor %}
|
2019-06-23 14:33:54 +02:00
|
|
|
{%- endif %}
|