|
- {%- import_yaml "openssh/defaults.yaml" as default_settings -%}
- {%- set ssh_config = salt['pillar.get']('ssh_config', default=default_settings.ssh_config, merge=True) -%}
-
- {%- set processed_options = [] -%}
-
- {%- macro render_raw_option(keyword, value) -%}
- {%- if value is sameas true -%}
- {{ keyword }} yes
- {%- elif value is sameas false -%}
- {{ keyword }} no
- {%- elif value is string or value is number -%}
- {{ keyword }} {{ value }}
- {%- else -%}
- {%- for single_value in value -%}
- {{ keyword }} {{ single_value }}
- {% endfor -%}
- {%- endif -%}
- {%- endmacro -%}
-
-
-
- {%- macro render_option(keyword, default, config_dict=ssh_config) -%}
- {%- set value = config_dict.get(keyword, default) -%}
- {{ render_raw_option(keyword, value) }}
- {%- endmacro -%}
-
-
- {%- macro option_impl(keyword, default, present) -%}
- {%- if present -%}
- {%- do processed_options.append(keyword) -%}
- {%- set prefix='' -%}
- {%- else -%}
- {%- set prefix='#' -%}
- {%- endif -%}
-
- {%- set keyword = prefix ~ keyword -%}
- {{ render_option(keyword, default) }}
- {%- endmacro -%}
-
-
- {%- macro option(keyword, default, present) -%}
- {{ option_impl(keyword, default, keyword in ssh_config) }}
- {%- endmacro -%}
-
-
- {%- macro option_default_uncommented(keyword, default, present) -%}
- {{ option_impl(keyword, default, True) }}
- {%- endmacro -%}
-
- # Do not edit this file manually!
- # It will be overwritten by salt!
-
- {%- if 'Hosts' in ssh_config %}
- {%- do processed_options.append('Hosts') %}
- {% for host, conf in ssh_config['Hosts'].items() %}
- Host {{ host }}
- {%- for key, val in conf.items() %}
- {{ render_raw_option(key, val) }}
- {%- endfor %}
- {%- endfor %}
- {%- endif %}
-
-
- {%- for keyword in ssh_config.keys() %}
-
- {%- if not keyword in processed_options and keyword != 'matches' -%}
-
- {{ render_option(keyword, '') }}
- {%- endif -%}
- {%- endfor %}
-
-
- {%- if 'matches' in ssh_config %}
- {%- for match in ssh_config['matches'].values() %}
- Match {{ match['type'].keys()[0] }} {{ match['type'].values()[0] }}
- {%- for keyword in match['options'].keys() %}
- {{ render_option(keyword, '', config_dict=match['options']) }}
- {%- endfor %}
- {%- endfor %}
- {%- endif %}
|