Custom deployment policies
If the built-in deployment policies included with Continuous Delivery don't align with how your organization uses PE, you can write custom deployment policies tailored to your needs.
When you create a custom deployment policy, you declare the steps that need to happen to deploy your Puppet code changes. Because custom deployment policies use Bolt plans, you can configure your policies to automate your deployment workflow processes. This means your custom policies can:
- Include Git processes in your chosen source control provider.
- Use Puppet orchestrator to make changes to your node groups.
- Run Bolt tasks and plans
- Issue automatic notifications via the third-party services, such as Slack and ServiceNow
Custom deployment policies use the puppetlabs-cd4pe_deployments
module, which is built into Continuous Delivery. This means you don't need to download or install
anything in order to use custom deployment policies. For a full list of functions and
variables you can use in your custom deployment policies, refer to the puppetlabs-cd4pe_deployments
module's README and REFERENCE on GitHub. Also in the module's GitHub repository, we've rewritten the built-in deployment policies as custom
policies so you can use these examples when writing your own policies.
Warnings and restrictions
Related information
Add a custom deployment policy to your control repo
Each custom deployment policy file must be stored in a module, named deployments
, in the control repo that uses the policy.
By default, Continuous Delivery looks for custom deployment policies on the
production
branch. If your control repo
doesn't have a production
branch, or you want to store
custom deployment policies on a different branch, you must manage your pipelines as
code and tell Continuous Delivery where to find your custom
deployment policy files. To direct Continuous Delivery to
branch other than production
:
- Open the pipeline's
.cd4pe.yaml
file. - Locate the
config
section. - Set
deployment_policy_branch
to the branch where the custom deployment policy files are stored.
For information about pipelines-as-code and .cd4pe.yaml
files, refer to Construct pipelines from code and
.cd4pe.yaml file structure.
production
branch, or you want to store custom deployment policies on
a different branch, you must use pipelines-as-code and specify the deployment_policy_branch
setting, as explained
above.These requirements don't apply if your control repo has aproduction
branch and you'll store your
custom deployment policy files on that branch.
- Write your custom deployment policy, as explained in the
puppetlabs-cd4pe_deployments
module's README on GitHub. - In your control repo, go to the branch where your custom deployment policy
files are stored. This is either the
production
branch or another branch you specified in your pipeline's.cd4pe.yaml
file.If your control repo doesn't have aproduction
branch, or you want to store custom deployment policies on a different branch, you must use pipelines-as-code and specify thedeployment_policy_branch
setting, as explained above. - Create a new Puppet module named
deployments
, and store it in one of the following directories in your control repo:/modules
/site
/site-modules
You must store the module in one of these specific directories so Continuous Delivery can find and run your custom deployment policies.
- Add your custom deployment policy file to the
/plans
directory in thedeployments
module.