Pallet has a node-list provider, which you can use to connect pallet to a server rack or to existing virtual machines. To talk to these servers, you need to tell pallet IP addresses and which group they belong to. You create a compute service by instantiating a node-list provider with a sequence of nodes to provide that information.

Getting a node-list compute service

There are two ways you can obtain a compute service.

Instantiate directly

The group is used to match nodes to the group-specs that you use to define the configuration to apply.

(require 'pallet.compute)
(def my-data-center
  (pallet.compute/instantiate-provider
    "node-list"
    :node-list [["qa" "fullstack" "10.11.12.13" :ubuntu]
                ["fe" "tomcats" "10.11.12.14" :ubuntu]]))

or for pallet 0.7 or earlier:

(require 'pallet.compute)
(def my-data-center
  (pallet.compute/compute-service
    "node-list"
     :node-list [["qa" "fullstack" "10.11.12.13" :ubuntu]
                 ["fe" "tomcats" "10.11.12.14" :ubuntu]]))

Instantiate based on ~/.pallet/config.clj

If your nodes are fairly static, you may wish to just list them in ~/.pallet/config.clj.

(defpallet
  :services
  {:data-center {:provider "node-list"
                 :node-list [["qa" "fullstack" "10.11.12.13" :ubuntu]
                             ["fe" "tomcats" "10.11.12.14" :ubuntu]]})

You can then obtain the compute service using pallet.configure/compute-service.

(require 'pallet.configure)
(def my-data-center
  (pallet.configure/compute-service :data-center))

Assigning Nodes to groups

In the :node-list values above, the first value in each vector is a hostname, the second value a group name, the third an IP address and the last is the operating system distribution running on the node.

The group-name is used to match the nodes to a group-spec (passed to lift, see below). This allows you to target different commands to different nodes.

Specifying the SSH username and credentials

Pallet uses SSH to talk to your nodes. The default is to use your local username and your id_rsa key, and assumes that your account on the nodes has password-less sudo set up.

The credentials for ssh are specified using a user map, which can be constructed using pallet.utils/make-user. This user map can be passed to lift.

Running a command on each node

To test your configuration, trying running a simple ls command.

(require 'pallet.actions 'pallet.api)
(pallet.api/lift
 (pallet.api/group-spec
  "tomcats"
  :phases {:configure (pallet.api/plan-fn
                       (pallet.actions/exec-script ("ls")))})
 :compute my-data-center)

or for pallet 0.7 or earlier:

(require 'pallet.action.exec-script 'pallet.phase)
(pallet.core/lift
 (pallet.core/group-spec
  "tomcats"
  :phases {:configure (pallet.phase/phase-fn
                       (pallet.action.exec-script/exec-script ("ls")))})
 :compute my-data-center)