Support: 1-800-961-4454
Sales Chat
1-800-961-2888

Rackspace Cloudvent Calendar Day 18: Packer And Rackspace

2

In the spirit of the holiday season, I’m sharing some tips and features of our cloud that you may not know about. In this countdown I’ll have 24 posts for you, each covering a single topic or feature about Rackspace Cloud products. We’ll post one per day so keep checking back!

On day 11, we went over using Vagrant with the Rackspace Cloud. Today I want to cover another tool by Mitchell Hashimoto: Packer. Packer is a tool for creating identical images for multiple platforms from a single source configuration. Packer supports multiple cloud providers: Rackspace, AWS, Digital Ocean and others. Let’s look at how we can use Packer to make images on Rackspace. First, go ahead and install Packer.

Packer uses JSON templates to define an image. Packer takes this JSON and runs the builds defined, producing a machine image. For OpenStack-based clouds, the JSON would look similar to this:

{
  "builders":
  [
{
  "type": "openstack",
  "username": "YOUR_USERNAME",
  "password": "YOUR_APIKEY",
  "provider": "rackspace-us",
  "region": "ORD",
  "ssh_username": "root",
  "image_name": "Test image",
  "source_image": " 80fbcb55-b206-41f9-9bc2-2dd7aac6c061",
  "flavor": "2"
}
 ],

"provisioners": [{
    "type": "shell",
    "inline": [
      "sudo apt-get update",
      "sudo apt-get install -y mysql-server"
    ]
  }]
}

Here, we’re using the shell provisioner to install MySQL. You can use other provisioners as well like Chef, Puppet, Salt or Vagrant. This is a great way to bootstrap your Cloud Servers for further automation with a configuration management system. To actually build the server, just run the “packer build” command:

packer build template.json

Check back tomorrow for more!

About the Author

This is a post written and contributed by Hart Hoover.

Hart Hoover is a Cloud Strategist at Rackspace Hosting. Hoover started his career as a Racker in 2007 as a Linux Systems Administrator, providing technical support for dedicated servers. He moved to the cloud in 2009 to help design the Managed Cloud Servers support model. He has presented at various technical conferences, maintains and contributes to the Rackspace DevOps Blog, and advises Rackspace customers on best practices for cloud computing.


More
2 Comments

Hello, Hart!

I’ve tried to do this, but get an error:

➜ packer git:(master) ✗ packer build -only=openstack ubuntu64.json
openstack output will be in this color.

Build ‘openstack’ errored: Expected HTTP response code [200]; got 401 instead

==> Some builds didn’t complete successfully and had errors:
–> openstack: Expected HTTP response code [200]; got 401 instead

==> Builds finished but no artifacts were created.

➜ packer git:(master) ✗ packer –version
Packer v0.5.2.dev (8a1364dbd817bd93b4d694eee03b208a20c22ade+CHANGES)

Is it still actual with v2 version of API?

avatar evtuhovich on February 2, 2014 | Reply

@evtuhovich:disqus – This is due to the authentication method being used. Just posted an update to the relevant issue in the packer repo – https://github.com/mitchellh/packer/issues/827

avatar asmajlovic on February 12, 2014 | Reply

Leave a New Comment

(Required)


Racker Powered
©2014 Rackspace, US Inc.