Image may be NSFW.
Clik here to view.
So we went through Puppet configuration of deploying a functional Razor installation in the first part here.
Now let’s look into how we can get Puppet to manage our Razor environment, namely models, images, policies and brokers. For this we’re gonna start off with configurations for deploying the Debian Wheezy distribution and then go on to Ubuntu Precise.
Open up your Puppet node configuration (site.pp or similar) for your Razor deployment and add the following within your “node puppet” definition that we defined in Part 1:
rz_image { "debian_wheezy": ensure => present, type => 'os', version => 'beta4', source => "http://ftp.debian.org/debian/dists/wheezy/main/installer-amd64/current/images/netboot/mini.iso", }
Run “puppet agent -t” and you should see the following output:
Info: Applying configuration version '1355082848' Downloading rz_image from http://ftp.debian.org/debian/dists/wheezy/main/installer-amd64/current/images/netboot/mini.iso ... /Stage[main]//Node[puppet]/Rz_image[debian_wheezy]/ensure: created
Ok, so something got applied, now let’s run the following to verify that it worked:
root@puppet:~# razor image UUID => 2RdsxhDxOvnNii39AY3h56 Type => OS Install ISO Filename => mini.iso Path => /opt/razor/image/os/2RdsxhDxOvnNii39AY3h56 Status => Valid OS Name => debian_wheezy OS Version => beta4
Look at that! Automatic ISO download and image injection into Razor. Let’s keep going and add a model for Debian Wheezy as well:
rz_model { 'install_wheezy': ensure => present, description => 'Debian Wheezy', image => 'debian_wheezy', metadata => {'domainname' => 'purevirtual.lab', 'hostname_prefix' => 'debian-', 'root_password' => 'password'}, template => 'debian_wheezy', }
Run your Puppet agent again and this is what you should see:
Info: Applying configuration version '1355083415' /Stage[main]//Node[puppet]/Rz_model[install_wheezy]/ensure: created
Let’s verify that as well:
root@puppet:~# razor model Models Label Template Description UUID install_wheezy linux_deploy Debian Wheezy Model 4EBOggCnQG90P4qBUNT4zI
Now we’re getting somewhere!
Let’s define our broker (meaning what we’ll hand off to after OS provisioning is done, here we’ll use our Puppet installation) before we go further:
rz_broker { 'puppet_broker': ensure => present, plugin => 'puppet', servers => [ 'puppet.purevirtual.lab' ] }
Apply the broker configuration using “puppet agent -t”:
Info: Applying configuration version '1355084448' /Stage[main]//Node[puppet]/Rz_broker[puppet_broker]/ensure: created
After applying it, let’s verify it:
root@puppet:~# razor broker Broker Targets: Name Description Plugin Servers UUID Version puppet_broker puppet_broker puppet [puppet.purevirtual.lab] 6jvJa0SsZYt0vUEQzusb8y Default
Let’s create a Razor tag as well, shall we? Just to make sure that only the VMs with the correct hardware requirements gets installed with Debian Wheezy. Let’s call it.. hmm.. “halfagigofram”!
rz_tag { "halfagigofram": tag_label => "halfagigofram", tag_matcher => [ { 'key' => 'mk_hw_mem_size', 'compare' => 'equal', 'value' => "512MiB", } ], }
Apply it…
Info: Applying configuration version '1355084532' /Stage[main]//Node[puppet]/Rz_tag[halfagigofram]/ensure: created
And verify it!
root@puppet:~# razor tag Tag Rules Name Tags UUID Matchers [count] halfagigofram halfagigofram UHIdK6YlezPUnfevHtebY 1
Now let’s create a new Razor policy using everything we’ve done so far:
rz_policy { 'wheezy_policy': ensure => present, broker => 'puppet_broker', model => 'install_wheezy', enabled => 'true', tags => ['halfagigofram'], template => 'linux_deploy', maximum => 10, }
Last apply for today:
Info: Applying configuration version '1355084748' /Stage[main]//Node[puppet]/Rz_policy[wheezy_policy]/ensure: created
Verify the last part as well:
root@puppet:~# razor policy Policies # Enabled Label Tags Model Label #/Max Counter UUID 2 true wheezy_policy [halfagigofram] install_wheezy 1/10 1 4eAaj0CxKdQNtYD3SmDxk8
Let’s try it out! Boot up a VM with half a gig of ram (512MB for those who can’t process words) and see the magic happen:
root@puppet:~# razor node Discovered Nodes UUID Last Checkin Status Tags 7JHPaRlWkrmph5w8jdbvBw 3 sec A [halfagigofram,onlyonedisk,IntelCorporation,memsize_512MiB,cpus_1,vmware_vm,nics_1]
DONE! You now have a proper Puppet configuration for a Razor deployment of Debian Wheezy which will automatically get connected to Puppet after OS provisioning is complete, to do more interesting further application deployments. If you wonder if your node really got #puppetized, just do the following:
On the newly installed node:
cat /etc/puppet/puppet.conf <snip> certname = <LONG UUID> </snip>
On the Puppet server run:
puppet cert list --all
And verify that you actually see the certname UUID there as well with a “+”-sign in front of it, meaning it’s signed and ready to rock!
Ok, so some of you might wonder how a Ubuntu variant of this would look like (as I was using Ubuntu is all my previous examples). Well, it would look something along these lines:
rz_image { "ubuntu_precise": ensure => present, type => 'os', version => '12.04.1', source => "http://ftp.sunet.se/pub/os/Linux/distributions/ubuntu/ubuntu-cd/12.04.1/ubuntu-12.04.1-server-amd64.iso", } rz_model { 'install_ubuntu': ensure => present, description => 'Ubuntu Precise', image => 'ubuntu_precise', metadata => {' domainname' => 'purevirtual.lab', 'hostname_prefix' => 'ubuntu-', 'root_password' => 'password'}, template => 'ubuntu_precise', } rz_policy { 'precise_policy': ensure => present, broker => 'puppet_broker', model => 'install_ubuntu', enabled => 'true', tags => ['memsize_1GiB'], template => 'linux_deploy', maximum => 10, }
Run “puppet agent -t” once again to get everything set up:
Info: Applying configuration version '1355164222' Downloading rz_image from http://ftp.sunet.se/pub/os/Linux/distributions/ubuntu/ubuntu-cd/12.04.1/ubuntu-12.04.1-server-amd64.iso ... /Stage[main]//Node[puppet]/Rz_image[ubuntu_precise]/ensure: created /Stage[main]//Node[puppet]/Rz_model[install_ubuntu_precise]/ensure: created /Stage[main]//Node[puppet]/Rz_policy[ubuntu_precise_policy]/ensure: created
At last, verify it by checking “razor image”, “razor model” and “razor policy”. Now you have not just one but TWO operatingsystems ready to be deployed, well done you!
Please let me know in the comments how it worked out for you and what distributions you’ve deployed using this method. Enjoy Image may be NSFW.
Clik here to view.
References:
http://wiki.debian.org/OpenStackRazorHowto
https://github.com/puppetlabs/Razor/wiki
https://github.com/puppetlabs/puppetlabs-razor/wiki
Image may be NSFW.
Clik here to view.
Clik here to view.
