Initial commit
This commit is contained in:
		| @@ -0,0 +1,95 @@ | ||||
| # {{ ansible_managed }} | ||||
|  | ||||
| {# {% for config in  network_interfaces %} #} | ||||
| {% for config in item.1 %} | ||||
|  | ||||
| {%   if config.headline is defined %} | ||||
| #----------------------------- | ||||
| # {{ config.headline }} | ||||
| #----------------------------- | ||||
|  | ||||
| {%    endif %} | ||||
| {# {%   if config.auto is defined and config.auto is sameas true %} #} | ||||
| {%   if config.auto | default(loop.first) %} | ||||
| auto {{ config.device }} | ||||
| {%    endif %} | ||||
| {%   for stanza in config.allow | default([]) %} | ||||
| allow-{{ stanza }} | ||||
| {%   endfor -%} | ||||
|  | ||||
| iface {{ config.device }} {{ config.family | default('inet', true) }} {{ config.method | default('static', true) }} | ||||
| {%   set iface_keys = ['description', 'address', 'netmask', 'network', 'broadcast', 'gateway'] %} | ||||
| {%   for key in iface_keys %} | ||||
| {%     if key in config %} | ||||
|    {{ key }} {{ config[key] }} | ||||
| {%     endif %} | ||||
| {%   endfor -%} | ||||
|  | ||||
| {# nameservers #} | ||||
| {%-  if (config.nameservers is defined) and (0 < config.nameservers | length) %} | ||||
|  | ||||
|    # nameserver settings | ||||
|    dns-nameservers {{ config.nameservers | join(' ') }} | ||||
| {%   endif %} | ||||
| {%  if config.dns_search is defined %} | ||||
|    dns-search {{ config.dns_search }} | ||||
| {%   endif -%} | ||||
|  | ||||
| {# subnets #} | ||||
| {%-  if (config.subnets is defined) and (0 < config.subnets | length) %} | ||||
|  | ||||
|    # additional subnets | ||||
| {%     for subnet in config.subnets %} | ||||
|    up /sbin/ip addr add {{ subnet }} dev {{ config.device }} | ||||
|    down /sbin/ip addr del {{ subnet }} dev {{ config.device }} | ||||
| {%     endfor %} | ||||
| {%   endif -%} | ||||
|  | ||||
| {# bridge settings #} | ||||
| {%- if config['bridge'] is defined %} | ||||
|  | ||||
|    # bridge settings | ||||
| {%   for key in config.bridge %} | ||||
|    bridge_{{ key }} {{ config.bridge[key] }} | ||||
| {%   endfor %} | ||||
| {% endif -%} | ||||
|  | ||||
| {# bond parameters #} | ||||
| {%   set bond_keys = ['mode', 'miimon', 'downdelay', 'updelay', 'master', 'slaves', 'lacp-rate'] %} | ||||
| {%-  if (config.bond is defined) and (bond_keys | intersect(config.bond.keys())) -%} | ||||
|  | ||||
|    # bond parameters | ||||
| {%     for key in bond_keys %} | ||||
| {%       if key in config.bond -%} | ||||
|    bond-{{ key }} {{ config.bond[key] }} | ||||
| {%       endif %} | ||||
| {%     endfor %} | ||||
| {%   endif -%} | ||||
|  | ||||
| {# vlan #} | ||||
| {%   set vlan_keys = ['raw-device'] %} | ||||
| {%-  if (config.vlan is defined) and (vlan_keys | intersect(config.vlan.keys())) -%} | ||||
|  | ||||
|    # vlan | ||||
| {%     for key in vlan_keys %} | ||||
| {%       if key in config.vlan -%} | ||||
|    vlan-{{ key }} {{ config.vlan[key] }} | ||||
| {%       endif %} | ||||
| {%     endfor %} | ||||
| {%   endif -%} | ||||
|  | ||||
| {# hook scripts #} | ||||
| {%   set hook_keys = ['pre-up', 'up', 'post-up', 'pre-down', 'down', 'post-down'] %} | ||||
| {%-  if hook_keys | intersect(config.keys()) %} | ||||
|  | ||||
|    # hook scripts | ||||
| {%     for key in hook_keys %} | ||||
| {%       if key in config %} | ||||
| {%         for value in config[key] %} | ||||
|    {{ key }} {{ value }} | ||||
| {%         endfor %} | ||||
| {%       endif %} | ||||
| {%     endfor %} | ||||
| {%   endif %} | ||||
|  | ||||
| {% endfor %} | ||||
							
								
								
									
										24
									
								
								roles/network_interfaces/templates/etc/network/interfaces.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								roles/network_interfaces/templates/etc/network/interfaces.j2
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| # {{ ansible_managed }} | ||||
|  | ||||
| #----------------------------- | ||||
| # lo: loopback | ||||
| #----------------------------- | ||||
|  | ||||
| auto lo | ||||
| iface lo inet loopback | ||||
| {% if network_interfaces_additional_loopback_ip_v4|d() %} | ||||
| {% for ip in network_interfaces_additional_loopback_ip_v4 %} | ||||
|   up /sbin/ip addr add {{ ip }} dev lo | ||||
|   down /sbin/ip addr del {{ ip }} dev lo | ||||
| {% endfor %} | ||||
| {% endif -%} | ||||
|  | ||||
| iface lo inet6 loopback | ||||
| {% if network_interfaces_additional_loopback_ip_v6|d() %} | ||||
| {% for ip in network_interfaces_additional_loopback_ip_v6 %} | ||||
|   up /sbin/ip addr add {{ ip }} dev lo | ||||
|   down /sbin/ip addr del {{ ip }} dev lo | ||||
| {% endfor %} | ||||
| {% endif %} | ||||
|  | ||||
| source /etc/network/interfaces.d/* | ||||
		Reference in New Issue
	
	Block a user