1818 {% - endif -%}
1919{% - endmacro -%}
2020
21+ {% - macro render_host_option (keyword , value ) -%}
22+ {% - if value is sameas true %}
23+ {{ keyword }} yes
24+ {% - elif value is sameas false %}
25+ {{ keyword }} no
26+ {% - elif value is string or value is number %}
27+ {{ keyword }} {{ value }}
28+ {% - else -%}
29+ {% - if keyword in string_or_list_options %}
30+ {{ keyword }} {{ value|join(',') }}
31+ {% - else %}
32+ {% - for single_value in value -%}
33+ {{ keyword }} {{ single_value }}
34+ {% - endfor -%}
35+ {% - endif -%}
36+ {% - endif -%}
37+ {% - endmacro -%}
38+
2139{#- generic renderer used for ssh matches, known options, -#}
2240{#- and unknown options -#}
2341{% - macro render_option (keyword , default , config_dict =ssh_config ) -%}
85103{% - do processed_options .append ('Hosts' ) %}
86104{% for host , conf in ssh_config ['Hosts' ].items () %}
87105Host {{ host }}
88- {% - for key , val in conf .items () %}
89- {{ render_raw_option (key, val) }}
106+ {% - for key , val in conf .items () - %}
107+ {{ render_host_option (key, val) }}
90108 {% - endfor %}
91109{% - endfor %}
92110{% - endif %}
93111
94112{# Handling unknown in salt template options #}
95- {% - for keyword in ssh_config .keys () %}
113+ {% for keyword in ssh_config .keys () - %}
96114 {#- Matches have to be at the bottom and should be handled differently -#}
97115 {% - if not keyword in processed_options and keyword != 'matches' -%}
98116 {% - if not keyword in string_or_list_options -%}
@@ -103,17 +121,16 @@ Host {{ host }}
103121{{ option_string_or_list(keyword, '', True) }}
104122 {% - endif -%}
105123 {% - endif -%}
106- {% - endfor %}
124+ {% - endfor - %}
107125
108126{# Handle matches last as they need to go at the bottom #}
109- {% - if 'matches' in ssh_config %}
127+ {% if 'matches' in ssh_config - %}
110128 {% - for match in ssh_config ['matches' ].values () %}
111129Match {{ match['type'] .keys()[0] }} {{ match['type'] .values()[0] }}
112130 {% - for keyword in match ['options' ].keys () %}
113131 {{ render_option(keyword, '', config_dict=match['options'] ) }}
114132 {% - endfor %}
115133 {% - endfor %}
116- {% - endif %}
134+ {% - endif - %}
117135
118136{#- vim: set ft=jinja : #}
119-
0 commit comments