blob: 9ab7824cf5174aa971240b1442688023314191b6 [file] [log] [blame]
{#- Collect interface roles and params into the following dict:
# interface_role: # filename that will be included
# interface_name: # interface (eth0)
# interface_param1: value # optional parameters or empty dict
# interface_param2: value
# ...
#}
{%- set interface_roles = {} %}
{%- for interface_name, interface in node['interfaces'].items() %}
{%- if interface['role'] not in interface_roles %}
{%- set _ = interface_roles.update({interface['role']: {}}) %}
{%- endif %}
{%- set _ = interface_roles[interface['role']].update({interface_name: {}}) %}
{%- for param_name, param in interface.items() %}
{%- set _ = interface_roles[interface['role']][interface_name].update({param_name: param}) %}
{%- endfor %}
{%- endfor %}
{%- set _ = params.update({'linux_network_interfaces': "\n"}) %}
{%- for interfaces_role, interfaces in interface_roles.items() %}
{%- import ("{# interfaces #}/" + interfaces_role) as interface with context %}
{%- set _ = params.update({'linux_network_interfaces': params['linux_network_interfaces'] + interface|string }) %}
{%- endfor %}
- environment.{{ cookiecutter._env_name }}.linux_network_interface