Saltstack Official OpenSSH Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
905B

  1. {%- from "openssh/map.jinja" import openssh, sshd_config with context %}
  2. include:
  3. - openssh
  4. {%- if sshd_config %}
  5. sshd_config-with-ini:
  6. {#- Convert any tabs to a single space to prevent false positives #}
  7. {#- Ref: https://github.com/saltstack-formulas/openssh-formula/issues/162 #}
  8. {%- set regex_search_for_tabs = '^(\w+)\t+(\w)' %}
  9. {%- if salt['file.contains_regex'](openssh.sshd_config, regex_search_for_tabs) %}
  10. file.replace:
  11. - name: {{ openssh.sshd_config }}
  12. - pattern: {{ regex_search_for_tabs }}
  13. - repl: '\1 \2'
  14. - show_changes: True
  15. - require_in:
  16. - ini_manage: sshd_config-with-ini
  17. {%- endif %}
  18. ini.options_present:
  19. - name: {{ openssh.sshd_config }}
  20. - separator: ' '
  21. - watch_in:
  22. - service: {{ openssh.service }}
  23. - sections:
  24. {%- for k,v in sshd_config.items() %}
  25. {{ k }}: '{{ v }}'
  26. {%- endfor %}
  27. {%- endif %}