0
0
mirror of https://github.com/saltstack-formulas/openssh-formula.git synced 2024-11-28 03:28:09 +01:00
openssh-formula/openssh/config_ini.sls
Imran Iqbal 14966e9a09 fix(config_ini): convert tabs to single space to prevent false +ves (#163)
* Fix #162
* Check for any number of tabs after the keyword
* If found, replace them by a single space to match the `separator` used
  in the `ini_options.present` state
2019-06-23 14:33:54 +02:00

31 lines
905 B
Plaintext

{%- from "openssh/map.jinja" import openssh, sshd_config with context %}
include:
- openssh
{%- if sshd_config %}
sshd_config-with-ini:
{#- 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:
- ini_manage: sshd_config-with-ini
{%- endif %}
ini.options_present:
- name: {{ openssh.sshd_config }}
- separator: ' '
- watch_in:
- service: {{ openssh.service }}
- sections:
{%- for k,v in sshd_config.items() %}
{{ k }}: '{{ v }}'
{%- endfor %}
{%- endif %}