How the control repository works

Code management relies on version control to track, maintain, and deploy your Puppet code and data. The control repository (or control repo) is a Git repository that code management uses to manage environments in your infrastructure. When you update code and data in your control repo, code management updates your environments accordingly.

Code management creates and maintains environments based on the branches in your control repo. For example, if your control repo has a production branch, a development branch, and a testing branch, code management creates a production environment, a development environment, and a testing environment. Each environment has its own version of your Puppet code and data based on the contents of the corresponding branch.

Environments are created on the primary server at /etc/puppetlabs/code/environments. You can learn more About environments in the Puppet documentation.

When you enable code management, Puppet manages the environment directories and does not preserve existing environments. Existing environments with the same names as new ones are overwritten, and environments not represented in the control repo are erased. If you were already using environment directories, make sure you commit those files or code to the corresponding branches of your control repo (or back them up elsewhere) before you start configuring code management.

At minimum, a control repo includes:

  • A Git remote repository. This is where your control repo is stored on your version control host.
  • A default branch named production, rather than the usual Git default of master. You might have additional branches for other environments, such as development or testing.
  • A Puppetfile to manage your environment content.
  • An environment.conf file that modifies the $modulepath setting to allow environment-specific modules and settings.

There are two ways to create control repos. To ensure your control repo has the recommended structure, code examples, and configuration scripts, Create a control repository from the Puppet template. This template covers most customer situations. If you cannot access the internet or cannot download modules directly from the Forge because of your organization's security rules, Create an empty control repo and add the necessary files to it.

For Windows systems, make sure your version control is configured to use CRLF line endings. Check your version control host's documentation for instructions on how to do this.

It is possible to have multiple control repos, and you can use separate repos to contain your module content or other data. If you have multiple repos, you need to: