pallet.action documentation

Actions are the primitives that are called by crate functions.

Actions can have multiple implementations, but by default most are implemented as script to be executed on the remote node.

An action has an :execution, which is one of :aggregated, :in-sequence, :collected, :delayed-crate-fn or :aggregated-crate-fn.

Calls to :aggregated actions will be grouped, and run before :in-sequence actions. Calls to :collected actions will be grouped, and run after :in-sequence actions.

Calls to :delayed-crate-fn and :aggregated-crate-fn actions are evaluated at action plan translation time, which provides a mechanism for calling crate functions after all other crate functions have been called.

action-fn

fn

[action-inserter dispatch-val]

Returns the function for an implementation of an action from an action inserter.

action-options

fn

[session]

Return any action-options currently defined on the session.

assoc-action-options

fn

[m]

Set precedence modifiers defined on the session.

clj-action

macro

[args & impl]

Creates a clojure action with a :direct implementation.

clj-action-fn

macro

[args & impl]

Creates a clojure action with a :direct implementation. The first argument will be the session. The clojure code can not return a modified session (use a full action to do that.

declare-action

fn

[action-symbol metadata]

Declare an action. The action-name is a symbol (not necessarily referring to a Var).

The execution model can be specified using the :execution key in metadata, with one of the following possible values:

:in-sequence - The generated action will be applied to the node "in order", as it is defined lexically in the source crate. This is the default. :aggregated - All aggregated actions are applied to the node in the order they are defined, but before all :in-sequence actions. Note that all of the arguments to any given action function are gathered such that there is only ever one invocation of each fn within each phase. :collected - All collected actions are applied to the node in the order they are defined, but after all :in-sequence action. Note that all of the arguments to any given action function are gathered such that there is only ever one invocation of each fn within each phase. :delayed-crate-fn - delayed crate functions are phase functions that are executed at action-plan translation time. :aggregated-crate-fn - aggregate crate functions are phase functions that are executed at action-plan translation time, with aggregated arguments, as for :aggregated.

declare-aggregated-crate-action

fn

[sym f]

Declare an action for an aggregated crate function. A delayed crate function becomes an action with a single, :default, implementation.

declare-collected-crate-action

fn

[sym f]

Declare an action for an collected crate function. A delayed crate function becomes an action with a single, :default, implementation.

declare-delayed-crate-action

fn

[sym f]

Declare an action for a delayed crate function. A delayed crate function becomes an action with a single, :default, implementation.

defaction

macro

[action-name attr-map? [params*]]

Declares a named action.

enter-scope

fn

[]

Enter a new action scope.

get-action-options

fn

[]

Return any action-options currently defined on the session.

implement-action

macro

[action-name dispatch-val attr-map? [params*]]

Define an implementation of an action. The dispatch-val is used to dispatch on.

implement-action*

fn

[action-inserter dispatch-val metadata f]

Define an implementation of an action given the action-inserter function.

implementation

fn

[{:keys [action], :as action-map} dispatch-val]

Returns the metadata and function for an implementation of an action from an action map.

insert-action

fn

[session action-map]

Registers an action map in the action plan for execution. This function is responsible for creating a node-value (as node-value-path's have to be unique for all instances of an aggregated action) as a handle to the value that will be returned when the action map is executed.

leave-scope

fn

[]

Leave the current action scope.

update-action-options

fn

[m]

Update any precedence modifiers defined on the session

with-action-options

macro

[m & body]

Set up local precedence relations between actions, and allows override of user options.

:script-dir : Controls the directory the script is executed in.

:sudo-user : Controls the user the action runs as.

:script-prefix : Specify a prefix for the script. Disable sudo using :no-sudo. Defaults to :sudo.

:script-env : Specify a map of environment variables.

:script-comments : Control the generation of script line number comments

:new-login-after-action : Force a new ssh login after the action. Useful if the action effects the login environment and you want the affect to be visible immediately.