f00bar.com

dev += ops

Knife-XAPI: Chef and Xenserver

| Comments

Knife-XAPI

Just finished making a knife plugin (my first) and gem (also my first) that enables knife xapi support. Right now it is only supporting guest create, but I plan on adding more commands in the near future.

you can install it with gem

1
gem install knife-xapi

Now you can spin up a guest on a Xen API host with knife. This is basic usage

1
2
3
knife xapi guest create "NewBox" "public"  \
  --xapi-vm-template "MyBaseBox" \
  --host http://sandbox/

The “NewBox” is the hosts name-label, and “public” would be the network name label you want to attach eth0 too. You can specify more networks as well:

1
2
3
knife xapi guest create "router" "public" "dmz" "private"  \
  --xapi-vm-template "MyBaseBox"  \
  --host http://sandbox/

This would build out a box basedon MyBaseBox template, and add 3 interfaces eth0/1/2 that are connected to those networks in the order specified.

The way I am using this now is to boot centos boxes and kickstart them at will. Using this more elaborate comandline:

1
2
3
4
5
knife xapi guest create "MySpiffyBox" "pub_network" \
 -B "dns=8.8.8.8 ks=http://192.168.6.4/repo/ks/default.ks ip=192.168.6.7 netmask=255.255.255.0 gateway=192.168.6.1" \
 -R http://192.168.6.5/repo/centos/5/os/x86_64 \
 -C 4 -M 4g -D 5g \
 -T "CentOS 5 (64-bit)" --host http://sandbox/

Here I am using the default xenserver 5 template to install a cent5 based vm with -T. Setting the VM Boot Arguments with -B that are instructing anaconda where to get the kickstart and how to setup the netinstalls networking. The -C switch is setting up 4 cpu’s on the guest. The -M is allocating 4 gigs of mem and -D is creating the root disk (xvda) as a 5GB box. This particular kickstart is a minimal centos install. This kicks off my kickstart install and in ~3 minutes i have a fresh machine installed via knife.

TODO

This is the stuff i want to add into this plugin:

  • Fix SSL issues
  • Guest Destroy
  • Guest List
  • Network List
  • Network Create
  • Network Destroy
  • SR Management

I may or may not include this in the knife command:

  • VM Metrics
  • Host Metrics
  • VIF/VBD Metrics

Bugs

Right now the big one is that the XML::RPC client gem is not supporting a way for me to ignore SSL Self signed certs that xenservers ship with. So https:// will only work on properly signed api endpoints.

Source

You can grab poke/comment and help me make this better! Codes up on github

Sysctl LWRP for Chef

| Comments

About 2 years ago i wrote a hacky ohai plugin to push all sysctl values into node data, and then a crappy recipe that would run an exec if they didn’t match values in node-data. A few months back i re-wrote all this to just use an lwrp that would just set these value, and a recipe that would pull them from attributes. So if you want to be able to see what nodes have huge pages enabled or whatnot.

Today I took some time to clean up the readme and release that code for others to hopefully find useful.

Octopressed

| Comments

Posterous just doesn’t support markdown very well, and every time I felt like writing a blog entry I would get frustrated. So after a couple people have expressed their pleasure with tools like jekyll using github pages. I decided to give it a go.

I love this setup. I tried jumping in with octopress without the rtfm. Having never setup github pages before i mucked up by creating a project site vs a user site, but once I fixed that (by creating a spheromak.github.com repo) everything clicked in.

Pulling old posterous posts down into jekyll was simple, and now im off and running with real markdown blog. Backed by git, and I am happier for it.

So thanks github, jekyll, and octopress for cool software that works

XenServer and Shadow Passwords

| Comments

Why doesn’t XenServer enable shadow passwords or authconfig.  What year is this  1996 ? My guess is so that it can readd the hashed root without privs for things like xencenter to be able to edit the passwd via xapi. Tho i don’t see any password manipulation api hooks.  I am really curious why this isnt set.

I have been manually (well chef does it)  setting the dom0 passwords to shadow by detecting if its a xenserver and running pwconv. There hasn’t been any repercussions in the last 3 years.

Untill now.

Now moving up to xen6 in my test pool im running into all sortsa auth isues requireing me to single user my upgraded Hosts and pwconv and passwd them. Blargh.

Arch Linux Developer Vagrant Box

| Comments

Vagrant is sweet!, but there wasn’t a lot of arch boxes out there that i could find. So heres my Vagrantfile.

if you don’t already use Vagrant you should. If you are doing any dev you should use it! if your an ops person then you should use it, and tell your developers about it. If you are a nerd you should use Vagrant. Nuf said.

Arch is also pretty sweet. Arch Linux has a system approach that rings totally right with me (I feel another post about arch in here someplace). Mainly Arch lets you do what you want how you want which is awesome!

Anyhow I have a little pet project that originally I was gonna do an LFS build up on, but realized arch already had a lot of what I needed. systemd support, and an not ancient/screwed up ruby install.

  • My build deviates from base arch in these ways:
    • It’s running 3.0.4 Kernel
    • Using systemd (with option to boot sysv)
    • full developer toolchain.
    • ABS the source build system for Arch.
    • Its big! ~1.2GB for a base box is pretty big, but its cause of all the build crap + kernel source

Lastly heres the links to the base box if you don’t want to get it via the vagrantfile.

Simple Robust OS Detection in Bash Using $OSTYPE

| Comments

I was using lazyweb to solve this problem. Google’s results had solutions where people were calling all sorts of commands and parsing different files to detect system types. I didn’t want to do a syscall. I wanted this solution to be as platform independant as possible. I only needed to know if it was linux/solaris/osx/bsd etc etc.  Not version or somehting special. SImple enough. 1 minute of RTFM’n the bash manual turned up $OSTYPE and $HOSTTYPE

Man I love simple solutions!

P.S. First post!

P.P.S posterious’s syntax support sucks. took longer to figure out than this post did to write.

edit: converted to markdown used gist for code highlight