Skip to content

Instantly share code, notes, and snippets.

@mattpascoe
Created October 12, 2012 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpascoe/3880158 to your computer and use it in GitHub Desktop.
Save mattpascoe/3880158 to your computer and use it in GitHub Desktop.
OpenNetAdmin puppet module stuffs
class opennetadmin::dcm inherits opennetadmin {
case $operatingsystem {
Debian,Ubuntu: {
package {
'libio-socket-ssl-perl':
ensure => present,
before => File['dcm.pl'],
}
}
default: { fail("Module ${title} isn't supported on ${operatingsystem}") }
}
# The dcm script
file {
'dcm.pl':
path => "${onabase}/bin/dcm.pl",
owner => root,
group => root,
mode => 0755,
backup => false,
source => 'puppet:///opennetadmin/dcm.pl';
# dcm configuration
# TODO: Change to a template and pass in the url instead of a static file
'dcm.conf':
path => "${onabase}/etc/dcm.conf",
mode => 0644,
owner => root,
group => root,
backup => false,
source => 'puppet:///opennetadmin/dcm.conf';
}
}
#
# This class will install a dhcpserver that is managed using OpenNetAdmin
#
class opennetadmin::dhcpd inherits opennetadmin {
case $operatingsystem {
Debian,Ubuntu: {
package { 'dhcp3-server': ensure => present; }
# Make sure the directory exists for our files
file {
"${onabase}/etc/dhcpd":
ensure => 'directory',
before => File['/etc/dhcp3/dhcpd.conf'],
;
# This links the default config to the ONA managed config
'/etc/dhcp3/dhcpd.conf':
ensure => link,
target => '/opt/ona/etc/dhcpd/dhcpd.conf.ona',
require => Package['dhcp3-server'],
;
# get the build script
'build_dhcpd':
path => "${onabase}/bin/build_dhcpd",
mode => 0750,
owner => root,
group => root,
backup => false,
source => 'puppet:///opennetadmin/build_dhcpd',
;
# add default dhcp config that uses ONA
'dhcpd.conf.ona.header':
mode => 0644,
path => "${onabase}/etc/dhcpd/dhcpd.conf.ona.header",
owner => root,
group => root,
backup => false,
source => 'puppet:///opennetadmin/dhcpd.conf.ona.header',
;
# add updated apparmor.d profile
# this will require a apparmor refresh
# TODO: figure out how to do a one time apparmor restart
'usr.sbin.dhcpd3':
path => '/etc/apparmor.d/usr.sbin.dhcpd3',
owner => root,
group => root,
mode => 0644,
backup => false,
require => Package['dhcp3-server'],
source => 'puppet:///opennetadmin/usr.sbin.dhcpd3',
;
# enable the cron job
'dhcpbuildcron':
mode => 0644,
path => '/etc/cron.d/dhcpd',
owner => root,
group => root,
backup => false,
source => 'puppet:///opennetadmin/cronentry',
;
}
# TODO: First run may fail if ona has not extracted a conf yet.
# Requires the server to be defined in ONA for at least
# the subnets it has interfaces on.
service {
'dhcp3-server':
ensure => running,
enable => true,
require => [ Package['dhcp3-server'],
File['/etc/dhcp3/dhcpd.conf'],
File['usr.sbin.dhcpd3'],
File['dhcpd.conf.ona.header'] ],
hasstatus => true,
;
}
}
default: {}
}
}
#
# opennetadmin.pp - ONA resources
#
class opennetadmin ( $onabase = '/opt/ona' ) {
file { '/etc/onabase':
mode => 644,
owner => root,
group => root,
before => File["$onabase"],
content => "${onabase}\n",
}
# Make sure the directory exists for our files
file {
[ $onabase, "${onabase}/bin", "${onabase}/etc" ]:
ensure => 'directory';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment