0
0
mirror of https://github.com/saltstack-formulas/openssh-formula.git synced 2026-05-17 23:20:02 +02:00

Removed redundant whitespace and comments

This commit is contained in:
Alexander Weidinger 2017-10-14 00:57:44 +02:00
parent f84bdcf377
commit 6bc6301c21

View File

@ -5,60 +5,60 @@
{#- generic renderer used for sshd matches, known options, -#} {#- generic renderer used for sshd matches, known options, -#}
{#- and unknown options -#} {#- and unknown options -#}
{%- macro render_option(keyword, config_dict=sshd_config) -%} {%- macro render_option(keyword, config_dict=sshd_config) -%}
{%- set value = config_dict.get(keyword) -%} {%- set value = config_dict.get(keyword) -%}
{%- if value is sameas true -%} {%- if value is sameas true -%}
{{ keyword }} yes {{ keyword }} yes
{%- elif value is sameas false -%} {% elif value is sameas false -%}
{{ keyword }} no {{ keyword }} no
{%- elif value is string or value is number -%} {% elif value is string or value is number -%}
{{ keyword }} {{ value }} {{ keyword }} {{ value }}
{%- else -%} {% else -%}
{%- for single_value in value -%} {%- for single_value in value -%}
{{ keyword }} {{ single_value }} {{ keyword }} {{ single_value }}
{% endfor -%} {% endfor -%}
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}
{#- macros for render option if present -#} {#- macros for render option if present -#}
{%- macro option(keyword, present) -%} {%- macro option(keyword, present) -%}
{%- if keyword in sshd_config -%} {%- if keyword in sshd_config -%}
{%- do processed_options.append(keyword) -%} {%- do processed_options.append(keyword) -%}
{{ render_option(keyword) }} {{ render_option(keyword) }}
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}
{#- macro for collapsing a list into a string -#} {#- macro for collapsing a list into a string -#}
{%- macro option_collapselist(keyword, sep) -%} {%- macro option_collapselist(keyword, sep) -%}
{%- do processed_options.append(keyword) -%} {%- do processed_options.append(keyword) -%}
{{keyword}} {{sshd_config.get(keyword)|join(sep)}} {{ keyword }} {{ sshd_config.get(keyword) | join(sep) }}
{%- endmacro -%} {%- endmacro -%}
{#- macro for handling an option that can be specified as a list or a string -#} {#- macro for handling an option that can be specified as a list or a string -#}
{%- macro option_string_or_list(keyword, sep=',') -%} {%- macro option_string_or_list(keyword, sep=',') -%}
{%- if sshd_config.get(keyword, '') is string -%} {%- if sshd_config.get(keyword, '') is string -%}
{{ option(keyword) }} {{ option(keyword) }}
{%- else -%} {%- else -%}
{{ option_collapselist(keyword, sep) }} {{ option_collapselist(keyword, sep) }}
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}
{#- macro for conditionally joining a string, list or dict(keys) to just a string -#} {#- macro for conditionally joining a string, list or dict(keys) to just a string -#}
{%- macro join_to_string(src, keyword, sep=',') -%} {%- macro join_to_string(src, keyword, sep=',') -%}
{%- set srcval = src.get(keyword, '') -%} {%- set srcval = src.get(keyword, '') -%}
{%- if srcval is string -%} {%- if srcval is string -%}
{{ srcval }} {{ srcval }}
{%- elif srcval is mapping -%} {%- elif srcval is mapping -%}
{{ srcval.keys()|sort|join(sep) }} {{ srcval.keys() | sort | join(sep) }}
{%- else -%} {%- else -%}
{{ srcval|join(sep) }} {{ srcval | join(sep) }}
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}
{%- if sshd_config.get('ConfigBanner', False) -%} {%- if sshd_config.get('ConfigBanner', False) -%}
{%- do processed_options.append('ConfigBanner') -%} {%- do processed_options.append('ConfigBanner') -%}
{{ sshd_config['ConfigBanner'] }} {{ sshd_config['ConfigBanner'] }}
{%- else -%} {%- else -%}
# This file is managed by salt. Manual changes risk being overwritten. # This file is managed by salt. Manual changes risk being overwritten.
{%- endif %} {%- endif %}
{%- set global_src_url = salt ['pillar.get']('__formulas:print_template_url', None) %} {%- set global_src_url = salt ['pillar.get']('__formulas:print_template_url', None) %}
{%- set local_src_url = salt ['pillar.get']('openssh-formula:print_template_url', None) %} {%- set local_src_url = salt ['pillar.get']('openssh-formula:print_template_url', None) %}
@ -72,162 +72,162 @@
# quick reference. # quick reference.
# See the sshd_config(5) manpage for details # See the sshd_config(5) manpage for details
{#- Specifies which address family should be used by sshd(8). #} {#- Specifies which address family should be used by sshd(8). -#}
{#- Valid arguments are any, inet (use IPv4 only), or inet6 (use IPv6 only) #} {#- Valid arguments are any, inet (use IPv4 only), or inet6 (use IPv6 only) -#}
{{ option('AddressFamily') }} {{- option('AddressFamily') -}}
{#- What ports, IPs and protocols we listen for #} {#- What ports, IPs and protocols we listen for -#}
{{ option('Port') }} {{- option('Port') -}}
{#- Use these options to restrict which interfaces/protocols sshd will bind to #} {#- Use these options to restrict which interfaces/protocols sshd will bind to -#}
{{ option('ListenAddress') }} {{- option('ListenAddress') -}}
{{ option('Protocol') }} {{- option('Protocol') -}}
{#- HostKeys for protocol version 2 #} {#- HostKeys for protocol version 2 -#}
{{ option('HostKey') -}} {{- option('HostKey') -}}
#Privilege Separation is turned on for security {#- Privilege Separation is turned on for security -#}
{{ option('UsePrivilegeSeparation') }} {{- option('UsePrivilegeSeparation') -}}
{#- Lifetime and size of ephemeral version 1 server key #} {#- Lifetime and size of ephemeral version 1 server key -#}
{{ option('KeyRegenerationInterval') }} {{- option('KeyRegenerationInterval') -}}
{{ option('ServerKeyBits') }} {{- option('ServerKeyBits') -}}
{#- Logging #} {#- Logging -#}
{{ option('SyslogFacility') }} {{- option('SyslogFacility') -}}
{{ option('LogLevel') }} {{- option('LogLevel') -}}
{#- Session idle time out #} {#- Session idle time out -#}
{{ option('ClientAliveInterval') }} {{- option('ClientAliveInterval') -}}
{{ option('ClientAliveCountMax') }} {{- option('ClientAliveCountMax') -}}
{#- Authentication: #} {#- Authentication: -#}
{{ option('LoginGraceTime') }} {{- option('LoginGraceTime') -}}
{{ option('PermitRootLogin') }} {{- option('PermitRootLogin') -}}
{{ option('StrictModes') }} {{- option('StrictModes') -}}
{{ option('MaxAuthTries') }} {{- option('MaxAuthTries') -}}
{{ option('MaxSessions') }} {{- option('MaxSessions') -}}
{{ option('DSAAuthentication') }} {{- option('DSAAuthentication') -}}
{{ option('RSAAuthentication') }} {{- option('RSAAuthentication') -}}
{{ option('PubkeyAuthentication') }} {{- option('PubkeyAuthentication') -}}
{{ option('AuthorizedKeysFile') }} {{- option('AuthorizedKeysFile') -}}
{{ option('AuthorizedKeysCommand') }} {{- option('AuthorizedKeysCommand') -}}
{{ option('AuthorizedKeysCommandUser') }} {{- option('AuthorizedKeysCommandUser') -}}
{#- Don't read the user's ~/.rhosts and ~/.shosts files #} {#- Don't read the user's ~/.rhosts and ~/.shosts files -#}
{{ option('IgnoreRhosts') }} {{- option('IgnoreRhosts') -}}
{#- For this to work you will also need host keys in /etc/ssh_known_hosts #} {#- For this to work you will also need host keys in /etc/ssh_known_hosts -#}
{{ option('RhostsRSAAuthentication') }} {{- option('RhostsRSAAuthentication') -}}
{#- similar for protocol version 2 #} {#- similar for protocol version 2 -#}
{{ option('HostbasedAuthentication') }} {{- option('HostbasedAuthentication') -}}
{#- Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication #} {#- Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication -#}
{{ option('IgnoreUserKnownHosts') }} {{- option('IgnoreUserKnownHosts') -}}
{#- To enable empty passwords, change to yes (NOT RECOMMENDED) #} {#- To enable empty passwords, change to yes (NOT RECOMMENDED) -#}
{{ option('PermitEmptyPasswords') }} {{- option('PermitEmptyPasswords') -}}
{#- Change to yes to enable challenge-response passwords (beware issues with #} {#- Change to yes to enable challenge-response passwords (beware issues with -#}
{#- some PAM modules and threads) #} {#- some PAM modules and threads) -#}
{{ option('ChallengeResponseAuthentication') }} {{- option('ChallengeResponseAuthentication') -}}
{{ option('AuthenticationMethods') }} {{- option('AuthenticationMethods') -}}
{#- Change to no to disable tunnelled clear text passwords #} {#- Change to no to disable tunnelled clear text passwords -#}
{{ option('PasswordAuthentication') }} {{- option('PasswordAuthentication') -}}
{#- Kerberos options #} {#- Kerberos options -#}
{{ option('KerberosAuthentication') }} {{- option('KerberosAuthentication') -}}
{{ option('KerberosGetAFSToken') }} {{- option('KerberosGetAFSToken') -}}
{{ option('KerberosOrLocalPasswd') }} {{- option('KerberosOrLocalPasswd') -}}
{{ option('KerberosTicketCleanup') }} {{- option('KerberosTicketCleanup') -}}
{#- GSSAPI options #} {#- GSSAPI options -#}
{{ option('GSSAPIAuthentication') }} {{- option('GSSAPIAuthentication') -}}
{{ option('GSSAPICleanupCredentials') }} {{- option('GSSAPICleanupCredentials') -}}
{{ option('X11Forwarding') }} {{- option('X11Forwarding') -}}
{{ option('AllowTcpForwarding') }} {{- option('AllowTcpForwarding') -}}
{{ option('X11DisplayOffset') }} {{- option('X11DisplayOffset') -}}
{{ option('PrintMotd') }} {{- option('PrintMotd') -}}
{# Bug in FreeBSD 10.3 (?) See https://lists.freebsd.org/pipermail/freebsd-stable/2016-April/084501.html #} {#- Bug in FreeBSD 10.3 (?) See https://lists.freebsd.org/pipermail/freebsd-stable/2016-April/084501.html -#}
{% if not (salt['grains.get']('os') == 'FreeBSD' and salt['grains.get']('osrelease')|float >= 10.3) -%} {% if not (salt['grains.get']('os') == 'FreeBSD' and salt['grains.get']('osrelease')|float >= 10.3) -%}
{{ option('PrintLastLog') }} {{- option('PrintLastLog') -}}
{% endif -%} {% endif -%}
{{ option('TCPKeepAlive') }} {{- option('TCPKeepAlive') -}}
{{ option('UseLogin') }} {{- option('UseLogin') -}}
{{ option('MaxStartups') }} {{- option('MaxStartups') -}}
{{ option('Banner') }} {{- option('Banner') -}}
{#- Allow client to pass locale environment variables #} {#- Allow client to pass locale environment variables -#}
{{ option('AcceptEnv') }} {{- option('AcceptEnv') -}}
{{ option('Subsystem') }} {{- option('Subsystem') -}}
{% if not salt['grains.get']('os') == 'OpenBSD' -%} {% if not salt['grains.get']('os') == 'OpenBSD' -%}
{#- Set this to 'yes' to enable PAM authentication, account processing, #} {#- Set this to 'yes' to enable PAM authentication, account processing, -#}
{#- and session processing. If this is enabled, PAM authentication will #} {#- and session processing. If this is enabled, PAM authentication will -#}
{#- be allowed through the ChallengeResponseAuthentication and #} {#- be allowed through the ChallengeResponseAuthentication and -#}
{#- PasswordAuthentication. Depending on your PAM configuration, #} {#- PasswordAuthentication. Depending on your PAM configuration, -#}
{#- PAM authentication via ChallengeResponseAuthentication may bypass #} {#- PAM authentication via ChallengeResponseAuthentication may bypass -#}
{#- the setting of "PermitRootLogin without-password". #} {#- the setting of "PermitRootLogin without-password". -#}
{#- If you just want the PAM account and session checks to run without #} {#- If you just want the PAM account and session checks to run without -#}
{#- PAM authentication, then enable this but set PasswordAuthentication #} {#- PAM authentication, then enable this but set PasswordAuthentication -#}
{#- and ChallengeResponseAuthentication to 'no'. #} {#- and ChallengeResponseAuthentication to 'no'. -#}
{{ option('UsePAM') }} {{- option('UsePAM') -}}
{%- endif %} {%- endif %}
{#- DNS resolve and map remote IP addresses #} {#- DNS resolve and map remote IP addresses -#}
{{ option('UseDNS') }} {{- option('UseDNS') -}}
{#- Restricting Users and Hosts #} {#- Restricting Users and Hosts -#}
{#- example: #} {#- example: -#}
{#- AllowUsers vader@10.0.0.1 maul@sproing.evil.com luke #} {#- AllowUsers vader@10.0.0.1 maul@sproing.evil.com luke -#}
{#- AllowGroups wheel staff #} {#- AllowGroups wheel staff -#}
#
{#- Keep in mind that using AllowUsers or AllowGroups means that anyone #} {#- Keep in mind that using AllowUsers or AllowGroups means that anyone -#}
{#- not Matching one of the supplied patterns will be denied access by default. #} {#- not Matching one of the supplied patterns will be denied access by default. -#}
{#- Also, in order for sshd to allow access based on full or partial hostnames it #} {#- Also, in order for sshd to allow access based on full or partial hostnames it -#}
{#- needs to to a DNS lookup #} {#- needs to to a DNS lookup -#}
#
{#- DenyUsers #} {#- DenyUsers -#}
{{ option_string_or_list('DenyUsers', sep=' ')}} {{- option_string_or_list('DenyUsers', sep=' ') -}}
{#- AllowUsers #} {#- AllowUsers -#}
{{ option_string_or_list('AllowUsers', sep=' ')}} {{- option_string_or_list('AllowUsers', sep=' ') -}}
{#- DenyGroups #} {#- DenyGroups -#}
{{ option_string_or_list('DenyGroups', sep=' ')}} {{- option_string_or_list('DenyGroups', sep=' ') -}}
{#- AllowGroups #} {#- AllowGroups -#}
{{ option_string_or_list('AllowGroups', sep=' ')}} {{- option_string_or_list('AllowGroups', sep=' ') -}}
{#- Specifies the available KEX (Key Exchange) algorithms. #} {#- Specifies the available KEX (Key Exchange) algorithms. -#}
{{ option_string_or_list('KexAlgorithms') }} {{- option_string_or_list('KexAlgorithms') -}}
{#- Specifies the ciphers allowed for protocol version 2. #} {#- Specifies the ciphers allowed for protocol version 2. -#}
{{ option_string_or_list('Ciphers') }} {{- option_string_or_list('Ciphers') -}}
{#- Specifies the available MAC (message authentication code) algorithms. #} {#- Specifies the available MAC (message authentication code) algorithms. -#}
{{ option_string_or_list('MACs') }} {{- option_string_or_list('MACs') -}}
{# Handling unknown in salt template options #} {#- Handling unknown in salt template options -#}
{%- for keyword in sshd_config.keys() %} {%- for keyword in sshd_config.keys() %}
{#- Matches have to be at the bottom and should be handled differently -#} {#- Matches have to be at the bottom and should be handled differently -#}
{%- if not keyword in processed_options and keyword != 'matches' -%} {%- if not keyword in processed_options and keyword != 'matches' -%}
{{ render_option(keyword) }} {{- render_option(keyword) -}}
{% endif -%} {% endif -%}
{%- endfor %} {%- endfor %}
{# Handle matches last as they need to go at the bottom #} {#- Handle matches last as they need to go at the bottom -#}
{%- if 'matches' in sshd_config %} {%- if 'matches' in sshd_config %}
{%- for name, match in sshd_config['matches']|dictsort(true) %} {%- for name, match in sshd_config['matches']|dictsort(true) %}
Match Match
{#- Set up the match criteria -#} {#- Set up the match criteria -#}
{%- for criteria in match['type'].keys()|sort() -%} {%- for criteria in match['type'].keys()|sort() -%}
{{- ' ' }}{{criteria }} {{ join_to_string(match['type'], criteria) -}} {{- ' ' -}}{{criteria -}} {{- join_to_string(match['type'], criteria) -}}
{%- endfor %} #{{ name }} {%- endfor %} #{{- name -}}
{#- Set up the applied options -#} {#- Set up the applied options -#}
{%- for keyword in match['options'].keys()|sort() %} {%- for keyword in match['options'].keys()|sort() %}
{{ render_option(keyword, config_dict=match['options']) }} {{- render_option(keyword, config_dict=match['options']) -}}
{%- endfor %} {%- endfor %}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{#- vim: set ft=jinja : #} {#- vim: set ft=jinja : -#}