Newer
Older
puppet-interfaces / manifests / iface.pp
  1. define interfaces::iface ( $family, $method, $options=[], $auto=0, $allow_hotplug=0, $ifname='UNSET' ) {
  2. case $family {
  3. inet: {
  4. if ! ($method in [loopback, static, manual, dhcp, bootp, ppp, wvdial]) {
  5. fail('method parameter must be one of loopback, static, manual, dhcp, bootp, ppp or wvdial for family inet')
  6. }
  7. }
  8. inet6: {
  9. if ! ($method in [loopback, static, manual, v4tunnel]) {
  10. fail('method parameter must be one of loopback, static, manual or v4tunnel for family inet6')
  11. }
  12. }
  13. ipx: {
  14. if ! ($method in [static, dynamic]) {
  15. fail('method parameter must be static or dynamic for family ipx')
  16. }
  17. }
  18. default: {
  19. fail('family parameter must be one of inet, inet6 or ipx')
  20. }
  21. }
  22.  
  23. $ifname_real = $ifname ? {
  24. 'UNSET' => $name,
  25. default => $ifname,
  26. }
  27.  
  28. if $auto == 1 {
  29. interfaces::auto { $ifname_real: }
  30. }
  31.  
  32. if $allow_hotplug == 1 {
  33. interfaces::allow { $ifname_real: subsystem => 'hotplug' }
  34. }
  35.  
  36. concat::fragment{"interfaces::iface_${name}":
  37. target => '/etc/network/interfaces',
  38. content => inline_template("iface <%= @ifname_real %> <%= @family %> <%= @method %>\n\t<%= @options.join('\n\t') %>\n\n"),
  39. }
  40. }