Skip to content

Instantly share code, notes, and snippets.

@hugoduncan
Created March 7, 2012 16:42
Show Gist options
  • Save hugoduncan/1994274 to your computer and use it in GitHub Desktop.
Save hugoduncan/1994274 to your computer and use it in GitHub Desktop.
new pallet first steps

Zero to running in five minutes with lein.

Install leiningen

The first thing we need is leiningen, a build tool for clojure. You can downlaod this with your web browser, curl or wget or your favourite download tool. Here we show using curl.

bash$ curl -O http://github.com/technomancy/leiningen/raw/stable/bin/lein
bash$ chmod +x lein

Create a new project

Now we can create a new clojure project using lein. To do this we install the pallet project template, then use it to creat a project named 'quickstart'.

bash$ lein plugin install lein-newnew 0.2.4
bash$ lein plugin install org.cloudhoist/lein-pallet-new 0.1.1-SNAPSHOT
bash$ lein new pallet quickstart
Created new project in: quickstart
bash$ cd quickstart

Configure your credentials

Now you can configure your credentials.

bash$ lein plugin install org.cloudhoist/pallet-lein 0.4.2-SNAPSHOT
bash$ lein pallet add-service aws aws-ec2 your-aws-key your-aws-secret-key

Note that this creates a ~/.pallet/services/aws.clj file with your credentials in it.

The second argument above is the name of the jclouds provider, which is cloud specific. To find the value for other clouds, you can list the supported providers with:

bash$ lein pallet providers

Start the REPL and load pallet

Start a repl with lein repl and load pallet with require at the repl user=> prompt.

(require 'pallet.core 'pallet.compute 'pallet.configure)

Start a cloud node

You can now start your first compute node:

(pallet.core/converge
  (pallet.core/group-spec "mygroup" 
    :count 1
    :node-spec (pallet.core/node-spec :image {:os-family :ubuntu}))
  :compute (pallet.configure/compute-service :aws))

To shut the node down again, change the :count value to zero:

(pallet.core/converge
  (pallet.core/group-spec "mygroup" 
    :count 0)
  :compute (pallet.configure/compute-service :aws))

Congratulations!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment