Skip to content

Instantly share code, notes, and snippets.

@igalic
Created October 18, 2013 06:28
Show Gist options
  • Save igalic/7037285 to your computer and use it in GitHub Desktop.
Save igalic/7037285 to your computer and use it in GitHub Desktop.
A short scrapping of how I use hiera+cobbler to setup my kvmhosts
---
# customize the installation of apache for cobbler
apache::default_vhost: false
cobblerdistros:
ubuntu-12.04.3-x86_64:
arch: x86_64
breed: ubuntu
os_version: precise
isolink: http://releases.ubuntu.com/12.04/ubuntu-12.04.3-server-amd64.iso
initrd: /srv/www/cobbler/ks_mirror/ubuntu-12.04.3-x86_64/install/netboot/ubuntu-installer/amd64/initrd.gz
kernel: /srv/www/cobbler/ks_mirror/ubuntu-12.04.3-x86_64/install/netboot/ubuntu-installer/amd64/linux
ks_meta:
tree: http://@@http_server@@/cblr/links/ubuntu-12.04.3-x86_64
cobblerprofiles:
internal:
distro: ubuntu-12.04.3-x86_64
virt_ram: 2048
virt_cpus: 2
virt_bridge: virbr0
kickstart: /srv/www/cobbler/ks_mirror/config/internal.cfg
external:
distro: ubuntu-12.04.3-x86_64
virt_ram: 2048
virt_cpus: 2
virt_bridge: virbr1
kernel_options:
netcfg/choose_interface: eth1
kickstart: /srv/www/cobbler/ks_mirror/config/external.cfg
# steak is a KVM Host.
---
# These IP addresses are needed to setup virbr1
#
# n.b.: We can't use facter for these values because as soon as we start
# managing /etc/network/interfaces the "facts will change".. in a way..
#
kvmhost::ip: 5.9.87.134
kvmhost::netmask: 255.255.255.224
kvmhost::gateway: 5.9.87.129
kvmhost::network: 5.9.87.128
kvmhost::broadcast: 5.9.87.159
# On steak we'll host the following Virtual Machines
cobblersystems:
# Move new ppmaster here.
ppmaster01.esotericsystems.at:
profile: external
hostname: ppmaster01.bblan
gateway: 5.9.103.121
interfaces:
eth0:
mac_address: 00:50:56:00:48:9D
ip_address: 5.9.103.122
netmask: 255.255.255.248
eth1:
ip_address: 192.168.122.122
netmask: 255.255.255.0
virt_bridge: virbr0
# mydb01.esat
mydb01.esat:
profile: internal
hostname: mydb01.esat
gateway: 192.168.122.1
interfaces:
eth0:
ip_address: 192.168.122.10
netmask: 255.255.255.0
# phpapp01.esat
phpapp01.esat:
profile: internal
hostname: phpapp01.esat
gateway: 192.168.122.1
interfaces:
eth0:
ip_address: 192.168.122.30
netmask: 255.255.255.0
# This will become our first new proxy!
prx01.esotericsystems.at:
profile: external
hostname: prx01.bblan
gateway: 5.9.103.137
interfaces:
eth0:
mac_address: 00:50:56:00:48:FE
ip_address: 5.9.103.142
netmask: 255.255.255.248
eth1:
ip_address: 192.168.122.50
netmask: 255.255.255.0
virt_bridge: virbr0
# nodes-prod.pp
node /steak|bacon/ {
$role = 'kvmhost'
class { 'base': } ->
class { 'kvmhost': }
}
node prx01 {
class { 'base': } ->
class { 'apps::lb': }
}
node phpapp01 {
$service = 'webapp'
class { 'base': } ->
class { 'apps::web': }
}
node mydb01 {
$role = 'db-server'
class { 'base': } ->
class { 'apps::db': }
}
node default {
include base
}
# == Class: kvmhost::config::cobbler
#
# This class is the global hook for configuration of cobbler
# Here we'll setup our repos and distros and other funk!
#
# === Parameters
#
# === Variables
#
# === Examples
#
# include 'kvmhost::config::cobbler'
#
# === Authors
#
# Brainsware <[email protected]>
#
# === Copyright
#
# Copyright 2013 Brainsware
#
class kvmhost::config::cobbler {
$cobblerdistros = hiera ('cobblerdistros', {})
$distrodefaults = { 'destdir' => $::cobbler::distro_path }
create_resources('cobblerdistro', $cobblerdistros, $distrodefaults)
$cobblerprofiles = hiera('cobblerprofiles', {})
$profiledefaults = {
'nameservers' => [ '176.9.94.130', '213.133.99.99', '213.133.100.100' ],
'virt_path' => 'vg0',
'virt_file_size' => '80',
'virt_type' => 'kvm',
'virt_auto_boot' => true,
'repos' => [],
'search' => [ 'esat.' ],
}
create_resources('cobblerprofile', $cobblerprofiles, $profiledefaults)
$cobblersystems = hiera('cobblersystems', {})
$systemdefaults = { 'power_type' => 'virsh' }
create_resources('cobblersystem', $cobblersystems, $systemdefaults)
}
# == Class: kvmhost::install::cobbler
#
# This class is the global hook for installation
#
# === Parameters
#
# === Variables
#
# === Examples
#
# include 'kvmhost::install::cobbler'
#
# === Authors
#
# Brainsware <[email protected]>
#
# === Copyright
#
# Copyright 2013 Brainsware
#
class kvmhost::install::cobbler {
# this is needed for powerr management!
package { 'fence-agents':
ensure => latest,
}
# Managing the apache installation on this server
# now happens in hiera's kvmhost role!
# However, we secure it here by only listening to private interfaces:
apache::listen {[
'192.168.122.1:80',
'127.0.0.1:80',
]:
}
# With those basics in place, we can get started with cobbler:
class { '::cobbler':
service_name => 'cobblerd',
webroot => '/srv/www/cobbler',
distro_path => '/srv/www/cobbler/ks_mirror',
server_ip => '192.168.122.1',
next_server_ip => '192.168.122.1',
allow_access => '192.168.122.1 127.0.0.1',
defaultrootpw => '$6$JdSUnsX8THgmQS4$U.djCmthXU7v9DbxQLLOYbicNOa8Yy1oroFj2RDjQu/RdwVI0lXN10.48qbFNRLrBiV41vKOFu2AFf4iBUQ0t1',
}
file { '/srv/www/cobbler/ks_mirror/config/internal.cfg':
source => 'puppet:///modules/kvmhost/internal.cfg',
require => Class[::cobbler],
}
file { '/srv/www/cobbler/ks_mirror/config/external.cfg':
source => 'puppet:///modules/kvmhost/external.cfg',
require => Class[::cobbler],
}
file { '/srv/www/cobbler/ks_mirror/config/puppet.conf':
source => 'puppet:///modules/kvmhost/puppet.conf',
require => Class[::cobbler],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment