by
tags:
As part of Tikal's 6th fuse day, our (ALM team) goal was to integrate Jenkins, Chef and OpenStack.
One of the tasks was to learn how to create an image that will be hosted on OpenStack cloud controller.
 
Looking over the net I have found some very useful tutorials that had guide me in creating windows and ubuntu images. 
Links to these tutorials are:
ubuntu   - https://help.ubuntu.com/12.04/serverguide/jeos-and-vmbuilder.html (Thanks to ubuntu documentation)
 
What I want to add in this post are some insights I have in addition to the above tutorials.
As for the windows tutorial, I have found that the following command did not work for me:
kvm -m 2048 -no-reboot -boot order=d -drive file=windowsr2.img,if=virtio,boot=off -drivefile=windows-2008r2.iso,media=cdrom,boot=on -drive file=virtio-win-0.1-30.iso,media=cdrom,boot=off -net nic,model=virtio -nographic -vnc :1
 
For some reason, the "-m" flag does not support numbers that are bigger than 2047 therefore I have used 2047 instead and everything worked smoothly after that.
Moreover, I had to enable Rdesktop on the windows machine to be able to connect from my host.
 
I still haven't tried to launch this image using Jenkins so I cannot add anything on this but image creation is being done by VNC connection to the image. It makes it easier to install what ever we need to make it work from Jenkins.
 
 
My main goal was to create a Ubuntu image that'll be able to be launched from Jenkins. The above tutorial explains perfectly how to create a ubuntu image for OpenStack. Problem was that I didn't know what do I need in order to make it work with Jenkins.
I have found out that I need the following packages:
openssh-server - obviously to be able to connect using ssh)
openjdk-7-jre     - for the jenkins slave
aptitude
cloud-init
 
So my final command was:
vmbuilder kvm ubuntu --suite precise --flavour virtual --arch amd64 -o --libvirt qemu:///system --user tikal --name tikal --pass tikal --addpkg openssh-server --addpkg openjdk-7-jre --addpkg aptitude --addpkg cloud-init
 
When the image was ready, I still had problems with creating a jenkins slave. I have found out that the jenkins is trying to run a command and constantly fails. I have launched that image and found that user tikal is part of sudoers but requires password in order to run sudo commands. I read some more about vmbuider and found out that vmbuilder uses a sudoers template file. This file lies under the following folder in Ubuntu OS:
/etc/vmbuilder/ubuntu/sudoers.tmpl
 
The default content looks like this:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
# Defaults

Defaults        !lecture,tty_tickets,!fqdn

# Uncomment to allow members of group sudo to not need a password
# %sudo ALL=NOPASSWD: ALL

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Members of the admin group may gain root privileges
­min ALL=(ALL) ALL
 
I have changed it to look like that before running the vmbuilder command:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
# Defaults

Defaults        !lecture,tty_tickets,!fqdn

# Uncomment to allow members of group sudo to not need a password
# %sudo ALL=NOPASSWD: ALL

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL
tikal ALL=NOPASSWD: ALL

# Members of the admin group may gain root privileges
#­min ALL=(ALL) ALL