Skip to content

Instantly share code, notes, and snippets.

Created August 24, 2017 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/db9cf0e70265221ff011494f660c0805 to your computer and use it in GitHub Desktop.
Save anonymous/db9cf0e70265221ff011494f660c0805 to your computer and use it in GitHub Desktop.
# Code:
{%-for device, value in salt.pillar.get('server:network', {}).iteritems() %}
{%-if value['set_type'] == "single" %}
auto {{device}}
iface {{device}} inet static
address {{value['set_ipaddress']}}
netmask {{value['set_netmask']}}
{%-if value['set_gateway'] is defined%}
gateway {{value['set_gateway']}}
{%-endif%}
{%-endif%}
{%-if value['set_type'] == "slave"%}
auto {{device}}
iface {{device}} inet manual
bond-master {{value['set_master']}}
{%endif%}
{%-if value['set_type'] == "bond-master"%}
auto {{device}}
iface {{device}} inet static
address {{value['set_ipaddress']}}
netmask {{value['set_netmask']}}
{%-if value['set_gateway'] is defined%}
gateway {{value['set_gateway']}}
{%-endif%}
bond-mode {{value['set_bond_type']}}
bond-miimon 100
bond-lacp-rate 1
bond-slaves {{value['set_bond_intf']}}
{%endif%}
{%-endfor%}
# Pillar
server:
network:
ens3:
set_type: "slave"
set_master: bond0
ens4:
set_type: "slave"
set_master: bond0
bond0:
set_type: "bond-master"
set_bond_intf: ens3 ens4
set_bond_type: 3+4
set_ipaddress: 172.18.0.51
set_netmask: 255.255.255.0
set_gateway: 172.18.0.254
# Output:
auto ens4
iface ens4 inet manual
bond-master bond0
auto bond0
iface bond0 inet static
address 172.18.0.51
netmask 255.255.255.0
gateway 172.18.0.254
bond-mode 3+4
bond-miimon 100
bond-lacp-rate 1
bond-slaves ens3 ens4
auto ens3
iface ens3 inet manual
bond-master bond0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment