Deploy module code

You can deploy new module code to your Puppet environments via a Continuous Delivery for PE module pipeline. To do so, you must first add a :branch => :control_branch declaration to the module's entry in your control repo's Puppetfile.

Module code is deployed to your Puppet environments using the eventual consistency deployment policy. When you trigger a module deployment, Continuous Delivery for PE creates a new branch in your module repository with the same name as your target Puppet environment. This new branch contains the code to be deployed.

Continuous Delivery for PE then triggers Code Manager, which reads the :branch => :control_branch declaration referring to the module in the control repo's Puppetfile and adds the new module code to the control repo. The new module code is now ready to be deployed to your chosen Puppet environments on the next scheduled Puppet run.

  1. Open the Puppetfile that includes the module you wish to deploy. Add a :branch => :control_branch declaration to the module's section of the Puppetfile, as in the following example.
    mod 'apache',
      :git    => 'https://github.com/puppetlabs/puppetlabs-apache',
      :branch => :control_branch, 
      :default_branch => 'main'
    To learn more about the :branch => :control_branch option, see Declare content from a relative control repo branch in the Code Manager documentation.
  2. If you are running Puppet Enterprise version 2019.0.x or any earlier version:
    1. Add the following to the top of your Puppetfile:
      def default_branch(default)
        begin
          match = /(.+)_(cdpe|cdpe_ia)_\d+$/.match(@librarian.environment.name)
          match ? match[1]:default
        rescue
          default
        end
      end
    2. Add the following :branch and :default_branch entries to the module entry in your Puppetfile:
      :branch => :control_branch, :default_branch => default_branch('main')
  3. In the Continuous Delivery for PE web UI, click Modules and select the module you wish to deploy.
  4. If you haven't already done so, create a pipeline for your module.
  5. Click + Add stage. Select Deployment.
  6. Select your PE instance and choose the Puppet environment the module code will be deployed to.
  7. Click Add deployment.
Results
Your module pipeline is now set up to deploy new module code to your chosen Puppet environments any time the pipeline is triggered.