April 10, 2014

Classes
Tags blog

Do More with Less: A SoftLayer Knife for Chef
<p>We're excited to announce the initial release of the <a href=https://github.com/softlayer/knife-softlayer>knife-sof

We're excited to announce the initial release of the knife-softlayer Ruby gem.

Knife-softlayer is a plugin for the knife utility used with Chef that allows users to launch a SoftLayer virtual server and bootstrap it in a single command. If you're new to Chef, here's a guide to get you started.

user@local> knife softlayer server create --hostname web --domain example.com --flavor medium

This is a basic example using every available default, but it works. It will launch a virtual server and register it as a Chef node (though it won't have a run list). The idea behind pushing your infrastructure into the cloud is that, ideally, you don't have to think about details that don't matter to you. We've worked hard to get the number of options you're required to supply (decisions you need to make) as low as possible, while still giving you full control over every single detail if you need it.

Unlike some other clouds, we don't take away your choices; however, we don't force you to choose if you don't want to think about it. We can't imagine why you would ever need a virtual server with 16 CPU cores and only 1GB of memory. But if that's what you need, with SoftLayer, you can do it.

This second example again launches an instance, this time specifying the number of cores, the NIC speed, the number and size of block devices, and also tells Chef to run a set of cookbooks on the instance. The virtual server is coming up with 1 core, 64GB of RAM, and 100GB of block device storage (disk space) on device 0. We're also installing git and redis on it.

user@local> knife softlayer server create -H some-host -D example.com \\
--network-interface-speed 1000 \\
--cores 1 \\
--ram 65536 \\
--block-storage 0:100 \\
--run-list 'recipe[git],recipe[redis]'

The knife-softlayer plugin will take any options that the regular bootstrap command supports, we've also added some additional options to support launching a SoftLayer virtual server.

Must Haves
  • -H,--hostname The hostname of the virtual server.
  • -D,--domain The domain of the virtual server.
The Big Three
  • -C, --cores will accept values from 1 - 16.
  • -R, --ram will accept values [in MB] from the following list:
    • 1024,2048,4096,6144,8192,12288,16384,32768,49152,65536
  • -B, --block-storage The size in GB of the block storage devices (disks) for this instance.
    • Specify 1 - 5 entries in a comma separated list following the format "dev:size". Example: "0:25,2:500" would be a 25GB volume on device 0 and a 100GB volume on on device 2. [NOTE: SoftLayer virtual servers always reserve device 1 for a swap device.] See knife softlayer flavor list --all for a list of available sizes.

Mix and match the above as you like!

OR, Just One
  • -f, --flavor Choose from a list of tiny, small, medium, large, xlarge and you can skip the three options above. Alternatively, choose a flavor that gets two of these right, and override the one you want to change by specifying only that flag.
user@local> knife softlayer server create --hostname web --domain example.com --flavor medium --cores 8

Check out knife softlayer flavor list for details on what each of these flavors will give you.

More Awesome Things
  • -n,--network-interface-speed in MB. See knife softlayer flavor list --all for available speeds.
  • -O,--os-code Defaults to UBUNTU_LATEST. See knife softlayer flavor list --all for available OS images.
  • --new-global-ip Provision a new Global IP address on your SoftLayer account and route it to the virtual server being created.
  • --assign-global-ip Pass an existing Global IP address to this option to route it to the virtual server being created.
  • --single-tenant Create a virtual server that has a private node, which means a dedicated physical host (get rid of those noisy neighbors).
  • --san-storage Don't bother with any local disks, use the SAN, instead of local storage, for the virtual servers instance storage.

See knife softlayer server create --help for the full list of awesome things.

A Whole Lot More

Combining the power of Chef with the flexibility of the SoftLayer API in a single utility brings a whole new level of fun to automating things in the SoftLayer cloud. Let us know what awesome things you're doing! We're on Twitter @softlayer.

-- Matt

If you have questions about or problems with knife-softlayer open an issue or email me


Feedback?

We would love to hear it
Open an issue