Added initial support for Debian and Ubuntu to network module
This commit is contained in:
parent
42a3a74b7b
commit
230c2c0e2b
5 changed files with 85 additions and 1 deletions
6
network/files/interfaces.in
Normal file
6
network/files/interfaces.in
Normal 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
|
|
@ -19,10 +19,44 @@ class network::helper::restart {
|
||||||
refreshonly => true,
|
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.
|
# Configure interface.
|
||||||
#
|
#
|
||||||
# === Parameters
|
# === Parameters
|
||||||
|
@ -93,6 +127,18 @@ define network::interface($options = [], $ipaddr = "none", $netmask = "none", $i
|
||||||
require => File["/etc/sysconfig/network-scripts/ifcfg-${name}"],
|
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: {
|
default: {
|
||||||
fail("Network module not supported in ${operatingsystem}")
|
fail("Network module not supported in ${operatingsystem}")
|
||||||
}
|
}
|
||||||
|
@ -137,6 +183,19 @@ define network::route($gateway, $device) {
|
||||||
notify => Exec["restart-network"],
|
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: {
|
default: {
|
||||||
fail("Network module not supported in ${operatingsystem}")
|
fail("Network module not supported in ${operatingsystem}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ HWADDR=<%= scope.lookupvar("macaddress_" + name) %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
BOOTPROTO=<%= proto %>
|
BOOTPROTO=<%= proto %>
|
||||||
<% if ipaddr != 'none' -%>
|
<% if ipaddr != 'none' and ipaddr != 'dhcp' -%>
|
||||||
IPADDR=<%= ipaddr %>
|
IPADDR=<%= ipaddr %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% if netmask != 'none' -%>
|
<% if netmask != 'none' -%>
|
||||||
|
|
3
network/templates/interfaces-gateway.erb
Normal file
3
network/templates/interfaces-gateway.erb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<% if gateway != 'none' -%>
|
||||||
|
gateway <%= gateway %>
|
||||||
|
<% end -%>
|
16
network/templates/interfaces-if.erb
Normal file
16
network/templates/interfaces-if.erb
Normal 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 -%>
|
Loading…
Add table
Reference in a new issue