[Puppet Users] Provisioning VM in Xen via Puppet - Howto??

1,349 views
Skip to first unread message

Gabriel - IP Guys

unread,
May 11, 2010, 3:48:10 PM5/11/10
to puppet...@googlegroups.com
Dear All,

I've finally managed to get xen installed on a remote system via puppet
http://puppetnewbie.blogspot.com/2010/05/installing-xen-instance.html

I was about to create my test machines manually, when it occurred to me,
that I should be doing this via puppet. Hence my question in the
subject. I was given some advice on the irc channel, but it didn't
really sink in very much.

If anyone has any ideas, please feel free to send me a note, I'll be
working on this privately, and post my findings and ideas, back to the
list. The way I have installed xen is noted in my blog if you would like
to reference it.

Thank you

The Puppet Apprentice :- http://puppetnewbie.blogspot.com/
Follow me on twitter :- http://twitter.com/mritguru
Puppet #tag on twitter :- #puppet
IRC :- itguru ON irc.freenode.org (feel free
to say hi!)

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Mike Seda

unread,
May 11, 2010, 10:35:18 PM5/11/10
to puppet...@googlegroups.com
All,
Does the file hierarchy provided below follow current best practices:

lib/
manifests/
---site.pp
---templates.pp
---nodes.pp
modules/
---{modulename}/
------depends/
------files/
------manifests/
---------init.pp
---------defaults.pp
------lib/
---------puppet/
------------parser/
---------------functions/
------------provider/
------------type/
---------facter/
------templates/
------README
---user/
---services/
---clients/
notes/
tools/

The aforementioned file hierarchy is based on the following links:
http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Best_Practice
http://docs.reductivelabs.com/guides/modules.html#internal_organisation

The only difference is that...
- the "services" and "clients" directories at the root of the hierarchy
have been made subdirectories of "modules"
- the "plugins" directory in the root of the hierarchy has been renamed
"lib"

Is this correct?

Mike

Thomas Bellman

unread,
May 12, 2010, 11:13:50 AM5/12/10
to puppet...@googlegroups.com
On 05/11/10 21:48, Gabriel - IP Guys wrote:

> I've finally managed to get xen installed on a remote system via puppet
> http://puppetnewbie.blogspot.com/2010/05/installing-xen-instance.html
>
> I was about to create my test machines manually, when it occurred to me,
> that I should be doing this via puppet. Hence my question in the
> subject. I was given some advice on the irc channel, but it didn't
> really sink in very much.
>
> If anyone has any ideas, please feel free to send me a note, I'll be
> working on this privately, and post my findings and ideas, back to the
> list. The way I have installed xen is noted in my blog if you would like
> to reference it.

First of all, I have a definition for creating Xen config files.
It is part of my 'nsc-puppet-utils' module, which you can clone
from <http://www.nsc.liu.se/~bellman/nsc-puppet-utils.git>. You
use it like this:

xen_domu {
myguest:
cpus => 2, memory => 4096,
interfaces => [ "00:16:3E:10:20:30", "00:16:3E:10:20:30" ],
disk => [ "/dev/vghost/vm-myguest.system",
"/dev/vghost/vm-myguest.homes" ],
ensure => running, autoboot => true;
}

There are more parameters available, but the above are perhaps
the most important. It is fairly generic, and tries to impose as
little "policy" as possible.

I then have another definition, which sets parameters the way I
want them to be. For each virtual guest, I actually create two
Xen config files; one for booting the guest the normal way, and
one for booting the CentOS installer with a kickstart file. To
install OS onto the disk image I do:

# xm create -c myguest-install

and let it run. To boot the machine after OS has been installed,
I do:

# xm create myguest

I use LVM logical volumes for disk images, using a consistent
naming for them, and my definition makes it easy to use that
convention. I use that definition like this:

nsc_vm_guest {
"mail":
memory => 3072, cpus => 3,
disk => [ "+postfix", "+spoolmail", "+home", "+mailman" ],
interfaces => [ "00:16:3E:10:20:30" ];
}

The "+foo" disk names is shorthand for /dev/vgbar/vm-mail.foo,
where "bar" is the name of the dom0 machine hosting the guest, so
I have less to type when defining my guests. nsc_vm_guest will
also automatically add a disk image for the system file systems
(/, /var and swap).

I don't create the logical volumes automatically, nor do I
partition or create filesystems on them automatically, to lessen
the risk of destroying important data. Except for /, /var and
swap, which my kickstart config creates; I make sure to keep
persistent data on separate filesystem from the OS filesystems,
so I can re-install machines with very little hesitation.


I'm attaching the nsc_vm_guest definition I use, and the
kickstart template I use. There is some documentation as
comments in there. If you use them, you will probably want
to customize them to your liking. Git clone the URL above
to get the nsc-puppet-utils module; hopefully it is generic
enough to not need any customization (but if you find that
you do, please tell me how it can be made better).


/Bellman
virtualization.pp
xenguest.ks.erb

Michael DeHaan

unread,
May 13, 2010, 1:57:26 PM5/13/10
to puppet...@googlegroups.com
On Tue, May 11, 2010 at 3:48 PM, Gabriel - IP Guys
<Gab...@impactteachers.com> wrote:
> Dear All,
>
> I've finally managed to get xen installed on a remote system via puppet
> http://puppetnewbie.blogspot.com/2010/05/installing-xen-instance.html
>
> I was about to create my test machines manually, when it occurred to me,
> that I should be doing this via puppet. Hence my question in the
> subject. I was given some advice on the irc channel, but it didn't
> really sink in very much.
>
> If anyone has any ideas, please feel free to send me a note, I'll be
> working on this privately, and post my findings and ideas, back to the
> list. The way I have installed xen is noted in my blog if you would like
> to reference it.

It's little consolation, but we have a Google Summer of Code project
(starting towards the end of this month) that will offer some very
nice provisioning and maintaince of Xen and qemu/KVM Puppet types
(using libvirt). You do not have long to wait :) No xm create or
virtinst commands will be required.

In the meantime, if you're running Fedora, CentOS, or RHEL, you may
want to take a look at the "koan" tool that comes with Cobbler, which
is a pretty good start to that kind of integration for creating VMs.
I am, however, a little biased :)

Even if you aren't using Puppet, I would highly recommend looking at
using Xen through libvirt tooling (virsh, virtinst, etc) rather than
/sbin/xm, then your investment in software to manage your
virtualization does not need to be repaid if you decide to switch
hypervisors.

--Michael

Dan Carley

unread,
May 14, 2010, 5:11:03 AM5/14/10
to puppet...@googlegroups.com
On 12 May 2010 16:13, Thomas Bellman <bel...@nsc.liu.se> wrote:
[..]
I don't create the logical volumes automatically, nor do I
partition or create filesystems on them automatically, to lessen
the risk of destroying important data.  

Good info. I do much the same - logical vols are managed by hand first.

Then initial booting of the domU is handled automatically with notify's to some exec{}'s so I don't have to log back in. Like:

exec { "xm_create_${domu_name}":
    command     => "/usr/sbin/xm create /etc/xen/auto/${domu_name}",
    unless      => "/usr/sbin/xm list ${domu_name} > /dev/null",
    refreshonly => true,
}

Christopher Johnston

unread,
Jun 11, 2010, 3:20:42 PM6/11/10
to puppet...@googlegroups.com
Thomas I don't see your GIT repo, looks to be offline.

Thomas Bellman

unread,
Jun 14, 2010, 9:33:44 AM6/14/10
to puppet...@googlegroups.com
On 2010-06-11 21:20, Christopher Johnston wrote:

> Thomas I don't see your GIT repo, looks to be offline.

I don't see any problems when I check now. A git clone of
http://www.nsc.liu.se/~bellman/nsc-puppet-utils.git works
fine for me. (Note, however, that you can't point a normal
web browser to that URL; you must use git-clone(1).)


/Bellman

Christopher Johnston

unread,
Jun 14, 2010, 10:18:59 AM6/14/10
to puppet...@googlegroups.com
My git clone was failing, will try again

Reply all
Reply to author
Forward
0 new messages