Puppet: System Administration Automated

Support

Those examples describe how to use templates to manage the networking settings.

Debian

The template is debian oriented.

3 files involved:

./nodes/box.pp
./functions/network-interfaces.pp
./templates/network/webserver

box.pp

node box {
        ...
        ...
        network-interfaces-tmpl { box:
                style => webserver,
                ip => "xx.xx.xx.xx",
                gateway => "xx.xx.xx.xx",
                broadcast => "xx.xx.xx.xx",
        }
        hosts { box: host => box }
}

webserver

auto lo
iface lo inet loopback

auto br0
iface br0 inet static
        address <%= ip %>
        netmask 255.255.255.0
        broadcast <%= broadcast %>
        gateway <%= gateway %>
        bridge_stp on
        bridge_ports eth0 eth1
        bridge_bridgeprio 60000
        bridge_maxwait 30

network-interfaces.pp

define network-interfaces-tmpl ($style, $ip, $broadcast = "xx.xx.xx.xx", $gateway = "xx.xx.xx.xx") {
        file { "/etc/network/interfaces":
                owner => root,
                group => root,
                mode => 644,
                content => template("network/$style")
        }
}

OpenBSD (for now) module

This aims to be a generic interface, but right now it's being written mostly for OpenBSD:

http://hg.koumbit.net/puppet-modules/file/tip/network/