Add code and set up Code Manager
Sections
Set up your control repo, create a Puppetfile, and configure Code Manager so you can start adding content to your Puppet Enterprise (PE) environments.
The control repo is where you store your code. Code in your control repo is usually bundled in modules.
The Puppetfile specifies detailed information about each environment's Puppet code and data, including where to get that code and data from, where to install it, and whether to update it.
Code Manager automates the management and deployment of your Puppet code. PE doesn't require Code Manager, but it is helpful for ensuring Puppet syncs code to your primary server and all your servers run new code at the same time.
Create a control repository from the Puppet template
To create a control repository (repo) that includes a standard recommended structure, code examples, and configuration scripts, base your control repo on the Puppet control repo template. This template covers most customer situations.
To base your control repo on the Puppet control repository template, you must set up a private SSH key (so your primary server can identify itself to your Git host), 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.
- An
environment.conf
file to implement asite-modules/
directory for roles, profiles, and custom modules. -
config_version
scripts to notify you which control repo version was applied to the agents. - Basic code examples for setting up roles and profiles.
- An example
hieradata
directory that matches the default hierarchy . - A Puppetfile to manage content maintained in your environment.
You now have a control repository based on the Puppet
control-repo
template. When you make changes to this
repo on your workstation and push those changes to the remote copy of the control
repo on your Git server, Code Manager deploys your infrastructure changes.
You also now have a Puppetfile available for you to start adding and managing content, like module code.
Configure Code Manager
Code Manager stages, commits, and synchronizes your code, automatically managing your environments and modules when you make changes.
Enable Code Manager
Set parameters in the console to enable Code Manager and connect your primary server to your Git repository.
pe-puppet
user to
access your Git repositories. The SSH key must be:- Owned by the
pe-puppet
user. - Located on the primary server.
- Located in a directory the
pe-puppet
user has permission to view, such as/etc/puppetlabs/puppetserver/ssh/id-control_repo.ed25519
.
These steps use the puppet job
command. To use this
command, you must have permission to run jobs and have access to the primary
server.
Set up authentication for Code Manager
To securely deploy environments, Code Manager needs an authentication token for both authentication and authorization.
Before requesting an authentication token, you must assign a user to the deployment role.
Request an authentication token for deployments
To securely deploy your code, request an authentication token for the deployment user.
The default lifetime for authentication tokens is one hour. You can use the Override
default expiry
permission set to change the token lifetime to a
duration better suited for a long-running, automated process.
Use the puppet-access
command to generate the authentication token.
The generated token is stored in a file for later use. The default token storage location is
~/.puppetlabs/token
. You can run puppet-access
show
to view the token.
Test the connection and deploy your code
Make sure Code Manager can connect to your control repository, make a test deployment to a single environment,and then deploy code to all environments.