How Code Manager works

To automatically manage your environments and modules, Code Manager uses r10k and the file sync service to stage, commit, and sync your code.

Code Manager requires Managing environments with a control repository. You must create a control repository with branches for each environment that you want to create (such as production, development, or testing). Each branch must have a Puppetfile specifying exactly which modules to install in each environment. You can learn more About Environments in the Puppet documentation.

Code Manager creates directory environments based on the branches you've set up. Your control repository lives on a Git server, and this is where you push code that you want Code Manager to deploy.

There are three ways to trigger Code Manager to start a code deployment:

  • A webhook from your Git server automatically starts the code deployment when you push code to the control repo.
  • Continuous Delivery sends a deploy request to Code Manager.
  • You use the puppet-code command to manually trigger Code Manager from the command line or with a custom script.

Once triggered, Code Manager uses r10k to fetch code from the Git server and places it into the staging directory on the primary server (at /etc/puppetlabs/code-staging). Next, the file sync storage service on the primary server detects the change in the staging directory, and the file sync clients pause Puppet Server to avoid conflicts during synchronization. Finally, the file sync clients synchronize the new code to the live code directories on the primary server and compilers (usually at /etc/puppetlabs/code). The following diagram illustrates this code deployment process.

Diagram of the Code Manager code deployment process.

Related information