Specify default values

Specify default option values for backup agents : commands, transports and notifiers

Although option values for backup commands, transport protocols and notifiers can be set at the agent-level, assigning default values is a convenient way to define settings globally. For example, there is a good chance you'll want your email delivery settings to be to be shared by all your jobs.

Specifying defaults

To specify default values, use the defaults_for verb in your Sheepfile, then indicate the type and name of the agent and the desired options:

defaults_for command: "mysql_dump",
	user: "backup",
	password: encrypted("encrypted_password")

defaults_for transport: "s3",
	access_key_id: "ABCDEF",
	secret_key: encrypted("encrypted_secret")

defaults_for notifier: "email",
	using: "sendmail",
  from: "[email protected]",
  to: "[email protected]"

host "my-app-host", hostname: "host.example.com"

job "my-db-backup" do
  resource "database", name: "my-database", host: "my-app-host"
  remotely as: "user" do
    mysql_dump # Use default user and password
    tar_gz delete_source: true
  move to: "localhost", using: "scp", as: "user"
  copy to: "my-bucket/my-project", using: "s3" # Use default credentials
  notify via: "email" # Use default delivery settings 

Refer to the documentation of individual commands, transports and notifiers for the list of all available options.


A word of warning

You'd better avoid assigning default values to destructive options and define them explicitely at the agent-level. For example, the delete_source option of the tar_gz command deletes its input after execution. It could be the desired behavior but defining it globally may be risky, especially if your Sheepfile contains a lot of jobs.

Overriding default values

To override default values, simply redefine them at the agent-level:

defaults_for notifier: "email",
	using: "sendmail",
  from: "[email protected]",
  to: "[email protected]"

job "my-backup" do
  notify via: "email", to: "[email protected]"