Create a control repository from the Puppet template
To create a control repository (or control repo) that has the recommended structure, code examples, and configuration scripts, base your control repo on the Puppet control repo template. This template covers most customer situations.
The Puppet control repo template contains the necessary files to configure a functioning code management control repo plus helpful Puppet code examples, including:
- Basic code examples for setting up roles and profiles.
- A Puppetfile that references modules to manage content in your environments.
- An example Code Manager configuration file and
hieradata
directory. - A
config_version
script that tells you which version of code from your control repo was applied to your agents. - An
environment.conf
file that implements theconfig_version
script and asite-modules
directory for roles, profiles, and custom modules.
In situations where you can't access the internet, or where organizational security policies prevent downloading modules from the Forge, you can Create an empty control repo and add the necessary files to it.
To use the template, you must set up a private SSH key, copy the control repo template to your development workstation, set your own remote Git repository as the default source, and then push the template contents to that source.
- To allow access to the control repo, generate a private SSH key without a password:
- To generate the key pair, run:
ssh-keygen -t ed25519 -P '' -f /etc/puppetlabs/puppetserver/ssh/id-control_repo.ed25519
- To allow the
pe-puppet
user to access the key, run:puppet infrastructure configure
Your private key is located at
/etc/puppetlabs/puppetserver/ssh/id-control_repo.ed25519
, and your public key is at/etc/puppetlabs/puppetserver/ssh/id-control_repo.ed25519.pub
. - Configure your Git host to use the SSH public key you generated. Usually, this involves creating a user or service account and assigning the SSH public key to it, but the exact process varies for each Git host. For instructions on adding SSH keys to your Git server, check your Git host's documentation (such as GitHub, BitBucket Server, or GitLab).Code management needs read access to your control repository, as well as any module repositories referenced in the Puppetfile.
- To generate the key pair, run:
- In your Git user account or organization, create
a repository named
control-repo
, and make sure a README is not automatically generated when you create the repo. Take note of the repo's SSH URL.Do not use an existing repo. The template requires a new, empty repo namedcontrol-repo
. - If you haven't already installed Git, run
yum install git
. - To clone the Puppet
control-repo
template, run:git clone https://github.com/puppetlabs/control-repo.git
- Change to the
control-repo
directory:cd control-repo
- Remove the template repo as the origin:
git remote remove origin
- Set your control repo as the origin:
git remote add origin <SSH_URL_FOR_YOUR_CONTROL_REPO>
- Push the contents of the
production
branch of the cloned control repo to your remote control repo:git push origin production
You now have a control repository based on the Puppet control-repo
template. After configuring Code Manager, when you make changes to your control repo
on your workstation and push the changes to the remote control repo on your Git host, Code Manager
detects and deploys your infrastructure changes.
By using the control-repo
template, you now also have
a Puppetfile to which you can add and manage content,
like module code.