Added initial support for Debian and Ubuntu to network module

This commit is contained in:
Ossi Salmi 2010-11-19 16:48:25 +02:00 committed by Timo Mkinen
parent 42a3a74b7b
commit 230c2c0e2b
5 changed files with 85 additions and 1 deletions

View file

@ -0,0 +1,6 @@
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback

View file

@ -19,8 +19,42 @@ class network::helper::restart {
refreshonly => true,
}
}
debian,ubuntu: {
exec { "restart-network":
command => "/etc/init.d/networking restart",
onlyif => "cat /etc/network/interfaces.in /etc/network/interfaces.d/*.conf > /etc/network/interfaces",
path => "/bin:/usr/bin:/sbin:/usr/sbin",
refreshonly => true,
}
}
}
}
# Install Debian/Ubuntu specific support files.
#
class network::helper::debian {
file { "/etc/network/interfaces.in":
ensure => present,
mode => 0644,
owner => root,
group => root,
source => "puppet:///network/interfaces.in",
}
file { "/etc/network/interfaces.d":
ensure => directory,
mode => 0644,
owner => root,
group => root,
purge => true,
force => true,
recurse => true,
source => "puppet:///custom/empty",
}
}
# Configure interface.
@ -93,6 +127,18 @@ define network::interface($options = [], $ipaddr = "none", $netmask = "none", $i
require => File["/etc/sysconfig/network-scripts/ifcfg-${name}"],
}
}
debian,ubuntu: {
include network::helper::debian
file { "/etc/network/interfaces.d/${name}.conf":
ensure => present,
content => template("network/interfaces-if.erb"),
mode => 0644,
owner => root,
group => root,
notify => Exec["restart-network"],
require => File["/etc/network/interfaces.d", "/etc/network/interfaces.in"],
}
}
default: {
fail("Network module not supported in ${operatingsystem}")
}
@ -137,6 +183,19 @@ define network::route($gateway, $device) {
notify => Exec["restart-network"],
}
}
debian,ubuntu: {
include network::helper::restart
include network::helper::debian
file { "/etc/network/interfaces.d/${device}-gateway.conf":
ensure => present,
content => template("network/interfaces-gateway.erb"),
mode => 0644,
owner => root,
group => root,
notify => Exec["restart-network"],
require => File["/etc/network/interfaces.d/${device}.conf"],
}
}
default: {
fail("Network module not supported in ${operatingsystem}")
}

View file

@ -4,7 +4,7 @@ HWADDR=<%= scope.lookupvar("macaddress_" + name) %>
<% end -%>
ONBOOT=yes
BOOTPROTO=<%= proto %>
<% if ipaddr != 'none' -%>
<% if ipaddr != 'none' and ipaddr != 'dhcp' -%>
IPADDR=<%= ipaddr %>
<% end -%>
<% if netmask != 'none' -%>

View file

@ -0,0 +1,3 @@
<% if gateway != 'none' -%>
gateway <%= gateway %>
<% end -%>

View file

@ -0,0 +1,16 @@
auto <%= name %>
<% if proto == 'none' -%>
iface <%= name %> inet manual
<% else -%>
iface <%= name %> inet <%= proto %>
<% end -%>
<% if ipaddr != 'none' and ipaddr != 'dhcp' -%>
address <%= ipaddr %>
<% end -%>
<% if netmask != 'none' -%>
netmask <%= netmask %>
<% end -%>
<% options.each do |val| -%>
<%= val %>
<% end -%>