The actions provide the basic primitives for pallet. These actions can be composed in plan functions to implement your configuration and operational requirements.

Direct Script Execution

Sometimes pallet's other actions will not suffice for what you would like to achieve, so the exec-script actions allow you to execute arbitrary script.

(exec-script* "ls some/path")
(exec-script (ls "some/path"))
(exec-checked-script "List some path" (ls "some/path"))

The exec-script* function will execute any bash script you pass it as a string.

exec-script is similar, but runs scripts written in pallet's embedded script DSL, stevedore.

exec-checked-script also uses stevedore, but will raise an error if the script exits with a non-zero exit code.

Simple File Management

Files can be managed using the file, symbolic-link, and fifo actions.

(file "some/path" :owner "user", :group "group", :mode "0644")
(symbolic-link "original/path" "link/path")
(fifo "some/path" :owner "user", :group "group", :mode "0644")

Simple Directory Management

Directories can be managed using the directory, and directories actions.

(directory "some/path" :owner "user", :path true)
(directories ["some/path" "other/path"] :owner "root")

File Contents

File contents can be manipulated with remote-file, remote-directory, rsync-directory and sed.

(remote-file "some/path" :content "Some content", :owner "user")
(remote-directory "some/path" :local-file "my.tar.gz")
(rsync-directory "local/path" "remote/path")

Note that remote-directory can unpack archives.


Packages can be controlled via package, packages, package-manager, package-source, add-rpm, and minimal-packages.

(package "some/path")
(packages :aptitiude ["git-core"] :yum ["git"])
(package-manager :update)
 "Partner" :aptitude {:url "" :scopes ["partner"]})

Users and Groups

Users and groups can be created and removed with user and group.

(user "tomcat" :system true, :shell "/bin/false", :group "tomcat")
(group "tomcat")


Init style services can be controlled with service, and init-script.

(service "tomcat" :action :restart)

Action Options

By default actions are run using sudo to the root user. You can modify this by using action options:

(require '[pallet.action :refer [with-action-options]])
(with-action-options {:script-dir "/var/log/app"}
  (remote-file "some/path" :content "Some content", :owner "user"))

Available options are:

:script-dir sets the directory the action will run in

:script-prefix sets the prefix for the command to run the action. This defaults to :sudo. At present, any other option, e.g. :no-sudo will run without sudo. See pallet.script-builder/prefix if you wish to add your own prefix commands, to run in a chroot, for example.

:script-env takes a map of environment variables and values to set for the action.

:sudo-user sets the user that sudo will be called with (when :script-prefix is :sudo, the default).

:new-login-after-action forces a new login session to be used for subsequent actions (i.e. after the completion of each action.