Custom deployment policies

If the built-in deployment policies included with Continuous Delivery for Puppet Enterprise (PE) don't align with how your organization uses PE, you can write custom deployment policies tailored to your needs.

CAUTION: Custom deployment policies are a beta feature. Documentation might be incomplete and you might experience some unexpected behavior or bugs. Please explore them at your own risk.
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 for PE. 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.

Custom deployment policy prerequisites and cautions

Restriction: To make your custom deployment policies available in the Continuous Delivery for PE web UI, you must have enabled webhooks between Continuous Delivery for PE and your source control system.
CAUTION: Do not include sensitive parameters in custom deployment policies that you use in pipelines-as-code.

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.

Before you begin
By default, Continuous Delivery for Puppet Enterprise (PE) 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 for PE where to find your custom deployment policy files.
To direct Continuous Delivery for PE to branch other than production:
  1. Open the pipeline's .cd4pe.yaml file.
  2. Locate the config section.
  3. 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 Structuring a .cd4pe.yaml file.

Important: If your control repo doesn't have a 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.

  1. Write your custom deployment policy, as explained in the puppetlabs-cd4pe_deployments module's README on GitHub.
  2. 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.
    Remember: If your control repo doesn't have a 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.
  3. 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 for PE can find and run your custom deployment policies.
  4. Add your custom deployment policy file to the /plans directory in the deployments module.