A phase specifies a sequence of actions or plan functions to be executed. A phase can be defined as part of a server-spec, or inline in a configure or lift invocation, using the plan-fn macro.

plan-fn macro

A plan function is just a plain clojure function.

The pallet.api/plan-fn macro is a convenience for defining a plan function. In the following example, the two server-spec definitions are functionally equivalent.

(require '[pallet.api :refer [group-spec node-spec plan-fn server-spec]])
(require '[pallet.actions :refer [package]])

(server-spec
  :phases {:configure (plan-fn (package "curl"))})

(server-spec
  :phases {:configure (fn [] (package "curl"))})

The plan-fn can also be named, in which case the name is used to provide context which is used in the log output.

:bootstrap

The :bootstrap phase is applied whenever pallet starts a new node.

:settings

The :settings phase is applied first, before any other phase. This phase is intended to provide configuration settings only, and to have no side-effects on the nodes.

:configure

The :configure phase is applied by default by both the converge and lift operations.

Inline phases

The :phase keyword in lift and converge can be used to carry out ad-hoc configuration or administration tasks. In this example we install curl on all running mytag nodes.

(require '[pallet.api :refer [group-spec node-spec lift plan-fn server-spec]])
(require '[pallet.actions :refer [package]])
(require '[pallet.configure :refer [compute-service]])

(lift (group-spec "mytag")
      :phase (plan-fn (package "curl"))
      :compute (pallet.configure/compute-service))