fabrica/.packer/provisioning/eole/2.7.2/modif/00-eole.yaml

78 lines
2.9 KiB
YAML

%set bonds = []
%set vlans = []
network:
version: 2
renderer: networkd
ethernets:
%for %%interface in range(0, %%int(%%nombre_interfaces)):
%set current_interface = 'eth' + str(%%interface)
%set interface_mode = %%getVar(%%current_interface + '_method')
%if %%getVar('activer_bonding_' + %%current_interface, "non") == 'non'
%%getVar('nom_zone_'+ %%current_interface):
%if %%interface_mode == 'statique' and %%getVar("adresse_ip_" + %%current_interface):
addresses:
- %%getVar("adresse_ip_" + %%current_interface)/%%calc_classe(%%getVar('adresse_netmask_' + %%current_interface))
%if %%getVar('alias_' + %%current_interface, "non") == "oui"
%for alias in %%getVar('alias_ip_' + %%current_interface)
- %%alias/%%calc_classe(getattr(alias, 'alias_netmask_' + %%current_interface))
%end for
%end if
%if %%interface_gw == %%getVar('nom_zone_' + %%current_interface):
gateway4: %%adresse_ip_gw
%end if
%if %%getVar('activer_ipv6') == "non"
dhcp6: no
accept-ra: no
optional-addresses: [ dhcp6 ]
%end if
%elif %%interface_mode == 'dhcp'
dhcp4: yes
%else
dhcp4: no
%end if
%else
%%bonds.append(%%current_interface)
%for %%slave in %%getVar('nom_carte_' + %%current_interface):
%%slave:
optional: false
%end for
%end if
%if %%getVar('vlan_' + %%current_interface, 'non') == 'oui'
%%vlans.append(%%current_interface)
%end if
%end for
%if len(%%bonds) > 0:
bonds:
%for bond in %%bonds:
%set %%bond_mode = %%getVar(%%bond + '_method')
%%getVar('nom_zone_' + %%bond):
interfaces: [%%custom_join(%%getVar('nom_carte_' + %%bond),',')]
%if %%bond_mode == 'statique'
addresses: [ %%getVar("adresse_ip_" + %%bond)/%%calc_classe(%%getVar('adresse_netmask_' + %%bond))]
%elif %%bond_mode == 'dhcp'
dhcp4: yes
%else
dhcp4: no
%end if
parameters:
mode: %%getVar('bonding_mode_' + %%bond)
mii-monitor-interval: %%getVar('bonding_miimon_' + %%bond)
up-delay: %%getVar('bonding_updelay_' + %%bond)
down-delay: %%getVar('bonding_downdelay_' + %%bond)
%end for
%end if
%if len(vlans) > 0:
vlans:
%for vlan in %%vlans:
%for vlan_id in %%getVar('vlan_id_' + %%vlan):
vlan%%vlan_id:
id: %%vlan_id
link: %%getVar('nom_zone_' + %%vlan)
addresses: [ %%getattr(vlan_id, 'vlan_ip_' + %%vlan)/%%calc_classe(%%getattr(vlan_id, 'vlan_netmask_' + %%vlan)) ]
%end for
%end for
%end if