Ubuntu Chef Workstation for Joyent Public Cloud

A jump box in the cloud is nice, but when actively building Chef recipes it is more practical to work from a desktop. In this article I show how to set up a Chef Server in Joyent Public Cloud and use a Ubuntu Desktop as your Chef Workstation.

Create a chefserver SmartMachine

  1. Log into your account add click the Add a machine button
  2. Under Images | Select an Image search for chef and click on the chefserver box that appears
  3. Under Sizes select Small 1GB (an Extra Small won't provision successfully at the moment)
  4. Under Confirm & Customize click Provision
  5. Wait for it to show as Running (took around 10 minutes for me)

Create a Chef Client (PEM file) on the Chef Server SmartMachine

  1. Get onto the Chef Server as the Chef admin user: ssh admin@<chefserver-ip>
  2. Verify that the server was provisioned correctly: knife client list.  You should see admin, chef-validator and chef-webui listed.
  3. Create Chef Client (PEM file): knife client create <username> -d -a -f /tmp/<username>.pem.

Create a Knife client on the Ubuntu Desktop

  1. Install latest Chef: sudo gem install chef --no-ri --no-rdoc.
  2. Create the Chef configuration directory: mkdir ~/.chef.
  3. Download the Chef Client (PEM file): scp admin@<chefserver-ip>:/tmp/<username>.pem ~/.chef/.
  4. Download the Chef Validator (PEM file): scp admin@<chefserver-ip>:/etc/validation.pem ~/.chef/.
  5. Set up Knife configuration: knife configure:
    WARNING: No knife configuration file found
    Where should I put the config file? [/home/username/.chef/knife.rb] 
    Please enter the chef server URL: [] http://chefserver-ip:4000
    Please enter an existing username or clientname for the API: [alain] 
    Please enter the validation clientname: [chef-validator] 
    Please enter the location of the validation key: [/etc/chef/validation.pem] /home/username/.chef/validation.pem
    Please enter the path to a chef repository (or leave blank): 
    You must place your client key in:
    Before running commands with Knife!
    You must place your validation key in:
    Before generating instance data with Knife!
    Configuration file written to /home/username/.chef/knife.rb

Configure Chef Workstation for Joyent Public Cloud

  1. Install Knife Joyent: sudo apt-get install libxml2-dev libxslt1-dev && sudo gem install knife-joyent --no-ri --no-rdoc
  2. Configure Knife Joyent: add the following to ~/.chef/knife.rb:
    knife[:joyent_username] = 'user.name@example.com'
    knife[:joyent_keyname] = 'key_id' # look under SSH Keys in the Joyent Cloud web UI
    knife[:joyent_keyfile] = '/home/username/.ssh/id_rsa'
    knife[:joyent_api_url] = 'https://api.joyentcloud.com'
  3. Verify that Knife Joyent is working: knife joyent server list.
    Enter PEM pass phrase:
    ID                                    Name              State         Type          Image                     IPs                          RAM   Disk   Tags
    00000000-0000-0000-0000-000000000000  chefserver        running       smartmachine  sdc:sdc:chefserver:1.1.0              1 GB  30 GB
  4. Try to create a new SmartMachine with knife joyent server create -N "demo.example.net" --flavor "Extra Small 512 MB" -I 60ed3a3e-92c7-11e2-ba4a-9b6d5feaa0c4 -d joyent-smartmachine.
    • You should see demo.example.net listed under Nodes on http://<chefserver-ip>:4040 (log in as chef with the password from Credentials on the Machine page in the Joyent Cloud web UI)
  5. Next, we'll try to delete a Machine.  List your Machines with knife joyent server list and record the ID of one that IS NOT your chefserver.  Try to delete that non-chefserver SmartMachine.with knife joyent server delete <ID>.