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.
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 ofmaster
. You might have additional branches for other environments, such asdevelopment
ortesting
. - 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.
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:
- Configure the
repositories
setting in your code management tool's Git settings: - Map your sources.