Deploy module code
You can use a Continuous Delivery module pipeline to deploy
new module code to your Puppet environments. To do this, you
must add a :branch => :control_branch
declaration to the module's entry
in your control repo's Puppetfile.
Continuous Delivery uses the Eventual consistency policy to deploy module code to your Puppet environments. When you trigger a module code
deployment, Continuous Delivery creates a new branch in your module
repository with the same name as your target Puppet
environment. This new branch contains the module code you want to deploy. Then, Continuous Delivery triggers Code Manager.
Code Manager reads the module's :branch =>
:control_branch
declaration in the control repo's Puppetfile and adds the new module code to the
control repo. The new module code is delivered to each node in the specified Puppet environment during each node's next scheduled
Puppet run.
- Open the Puppetfile that includes the module you
want to deploy. Add a
:branch => :control_branch
declaration to the module's section of the Puppetfile. For example:mod 'apache', :git => 'https://github.com/puppetlabs/puppetlabs-apache', :branch => :control_branch, :default_branch => 'main'
To learn more about the
:branch => :control_branch
declaration, refer to Declare content from a relative control repo branch in PE's Code Manager documentation. - If you are running PE version 2019.0.z or
earlier: You must make two additional changes to the Puppetfile.
- Add the following code to the top of the Puppetfile:
def default_branch(default) begin match = /(.+)_(cdpe|cdpe_ia)_\d+$/.match(@librarian.environment.name) match ? match[1]:default rescue default end end
- Add the following
:branch
and:default_branch
entries to the module's entry in the Puppetfile::branch => :control_branch, :default_branch => default_branch('main')
- Add the following code to the top of the Puppetfile:
- In the Continuous Delivery web UI, go to Modules and select the module you want deploy.
- If you haven't already done so, Create a pipeline for your module.
- Click Add stage and select Deployment.
- Select your PE instance and choose the Puppet environment where you want to deploy the module code.
- Click Add deployment.
Your module pipeline can now deploy new module code to the chosen Puppet environments when the pipeline is triggered.