class network {
tag("bootstrap")
file { "ifcfg-eth0":
path => "/etc/sysconfig/network-scripts/ifcfg-eth0",
owner => root,
group => root,
mode => 644,
content => template("network/ifcfg.erb"),
ensure => present,
notify => Service[network],
}
file { "network":
path => "/etc/sysconfig/network",
owner => root,
group => root,
mode => 644,
content => template("network/network.erb"),
notify => Service[network],
}
service { network:
ensure => "running",
hasstatus => "true",
hasrestart => "true",
restart => "/etc/init.d/network restart",
}
}
[root@hlslinutil1]/root/puppet/modules/testing/network/templates# cat ifcfg.erb
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=<%= ip %>
BROADCAST=xxx
NETMASK=xxx
NETWORK=xxx
[root@hlslinutil1]/root/puppet/modules/testing/network/templates# cat network.erb
NETWORKING=yes
HOSTNAME=<%= fqdn %>
I actually have it slightly more complicated as I modified foreman to provide ip and then I have extra checks in the erb like:
<% if ip =~ /10.241.209/ %>
BROADCAST=10.241.209.255
NETMASK=255.255.255.0
NETWORK=10.241.209.0
Hopefully that'll start you on the right path.