Add $allow_hotplug shortcut to interfaces::iface
1 parent d6a58a5 commit 1d7dc7178881c56102c043e96763176f66445c1e
@Andreas Jaggi Andreas Jaggi authored on 18 Aug 2012
Showing 3 changed files
View
14
README.markdown
Standard example with a regular Ethernet interface configured for DHCP:
 
```
include interfaces
interfaces::iface { 'eth0': family => 'inet', method => 'dhcp', auto => 1 }
interfaces::iface { 'eth0': family => 'inet', method => 'dhcp', auto => 1, allow_hotplug => 1 }
```
 
Network interface with static addressing and VLAN with DHCP configuration:
```
include interfaces
interfaces::iface { 'eth0': family => 'inet', method => 'static', options => ['address 192.0.2.1','netmask 255.255.255.0','gateway 192.0.2.2'], auto => 1 }
interfaces::iface { 'eth0': family => 'inet', method => 'static', options => ['address 192.0.2.1','netmask 255.255.255.0','gateway 192.0.2.2'], auto => 1, allow_hotplug => 1 }
interfaces::iface { 'eth0.123': family => 'inet', method => 'dhcp', options => ['vlan_raw_device eth0'], auto => 1 }
```
 
Static IPv6 address configuration:
```
include interfaces
interfaces::iface { 'eth0': family => 'inet6', method => 'static', options => ['address 2001:db8::1','netmask 64'], auto => 1 }
interfaces::iface { 'eth0': family => 'inet6', method => 'static', options => ['address 2001:db8::1','netmask 64'], auto => 1, allow_hotplug => 1 }
```
 
Dualstack configuration:
```
include interfaces
interfaces::iface { 'eth0': family => 'inet', method => 'dhcp', auto => 1 }
interfaces::iface { 'eth0v6': ifname => 'eth0', family => 'inet6', method => 'static', options => ['address 2001:db8::1','netmask 64'], auto => 1 }
interfaces::iface { 'eth0': family => 'inet', method => 'dhcp', auto => 1, allow_hotplug => 1 }
interfaces::iface { 'eth0v6': ifname => 'eth0', family => 'inet6', method => 'static', options => ['address 2001:db8::1','netmask 64'] }
```
 
Reference:
----------
```
interfaces::auto()
interfaces::allow($subsystem)
interfaces::mapping($script, $maps=[])
interfaces::iface($family, $method, $options=[], $ifname=$name, $auto=0)
interfaces::iface($family, $method, $options=[], $ifname=$name, $auto=0, $allow_hotplug=0)
```
 
Currently the only shortcut is the $auto parameter of interfaces::iface which when set to 1 directly produces an interfaces::auto entry for the interface.
Currently the only shortcuts are the $auto parameter of interfaces::iface which when set to 1 directly produces an interfaces::auto entry for the interface and the $allow_hotplug parameter of interfaces::iface which when set to 1 directly produces an interfaces::allow hotplug subsystem entry for the interface.
View
6
manifests/iface.pp
define interfaces::iface ( $family, $method, $options=[], $auto=0, $ifname='UNSET' ) {
define interfaces::iface ( $family, $method, $options=[], $auto=0, $allow_hotplug=0, $ifname='UNSET' ) {
case $family {
inet: {
if ! ($method in [loopback, static, manual, dhcp, bootp, ppp, wvdial]) {
fail('method parameter must be one of loopback, static, manual, dhcp, bootp, ppp or wvdial for family inet')
if $auto == 1 {
interfaces::auto { $ifname_real: }
}
 
if $allow_hotplug == 1 {
interfaces::allow { $ifname_real: subsystem => 'hotplug' }
}
 
concat::fragment{"interfaces::iface_${name}":
target => '/etc/network/interfaces',
content => inline_template("iface <%= @ifname_real %> <%= @family %> <%= @method %>\n\t<%= @options.join('\n\t') %>\n\n"),
}
View
spec/defines/iface_spec.rb