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
- Log into your account add click the Add a machine button
- Under Images | Select an Image search for chef and click on the chefserver box that appears
- Under Sizes select Small 1GB (an Extra Small won't provision successfully at the moment)
- Under Confirm & Customize click Provision
- Wait for it to show as Running (took around 10 minutes for me)
Create a Chef Client (PEM file) on the Chef Server SmartMachine
- Get onto the Chef Server as the Chef admin user: ssh admin@<chefserver-ip>
- Verify that the server was provisioned correctly: knife client list. You should see admin, chef-validator and chef-webui listed.
- Create Chef Client (PEM file): knife client create <username> -d -a -f /tmp/<username>.pem.
Create a Knife client on the Ubuntu Desktop
- Install latest Chef: sudo gem install chef --no-ri --no-rdoc.
- Create the Chef configuration directory: mkdir ~/.chef.
- Download the Chef Client (PEM file): scp admin@<chefserver-ip>:/tmp/<username>.pem ~/.chef/.
- Download the Chef Validator (PEM file): scp admin@<chefserver-ip>:/etc/validation.pem ~/.chef/.
- 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://127.0.0.1:4000] 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
- Install Knife Joyent: sudo apt-get install libxml2-dev libxslt1-dev && sudo gem install knife-joyent --no-ri --no-rdoc
- Configure Knife Joyent: add the following to ~/.chef/knife.rb:
knife[:joyent_username] = 'email@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'
- 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 188.8.131.52 184.108.40.206 1 GB 30 GB
- 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.
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>.
- 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)