Skip to content

Post-deploy

(See Job Lifecycle for an explanation of when post-deploy scripts run.)

Note

This feature is available with bosh-release v255.4+ and only for releases deployed with 3125+ stemcells.

Note

Releases that make use of post-deploy scripts and are deployed on older stemcells or with an older Director may potentially deploy; however, post-deploy script will not be called.

Release job can have a post-deploy script that will run after all jobs in the deployments successfully started (and ran post-start scripts). This script allows the job to execute any additional commands against a whole deployment before considering deploy finished.


Director Configuration

Note

In current Director versions, post-deploy scripts will always run.

For Directors older than 280.0.23, the director.enable_post_deploy property was configurable and if not set, defaulted to true. Prior to 268.7.0, the property defaulted to false.


Job Configuration

To add a post-deploy script to a release job:

  1. Create a script with any name in the templates directory of a release job.
  2. In the templates section of the release job spec file, add the script name and the bin/post-deploy directory as a key value pair.

Example:

---
name: cassandra_node
templates:
  post-deploy.erb: bin/post-deploy

Script Implementation

Post-deploy script is usually just a regular shell script. Since post-deploy script is executed in a similar way as other release job scripts (start, stop, drain scripts) you can use job's package dependencies.

Post-deploy script should be idempotent. It may be called multiple times after process is successfully started.

Unlike a drain script, a post-deploy script uses an exit code to indicate its success (exit code 0) or failure (any other exit code).

Post-deploy script is called every time after job is started (ctl script is called) by the Director, which means that post-deploy script should perform its operations in an idempotent way.

Note

Running monit start directly on a VM will not trigger post-deploy scripts.

Post-deploy scripts in a deployment are executed in parallel.


Logs

You can find logs for each release job's post-deploy script in the following locations:

  • stdout in /var/vcap/sys/log/<job-name>/post-deploy.stdout.log
  • stderr in /var/vcap/sys/log/<job-name>/post-deploy.stderr.log

Since post-deploy script will be called multiple times, new output will be appended to the files above. Standard log rotation policy applies.