Add code and set up Code Manager
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 (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.
- Basic code examples for setting up roles and profiles.
- A Puppetfile that references modules to manage content in your environments.
- An example Hiera 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.
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.
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.
Next, set up authentication for Code Manager.
Set up authentication for Code Manager
To securely deploy environments, Code Manager needs an authentication token for both authentication and authorization.
Request an authentication token for deployments
To enable secure deployment of your code, request an authentication token for the deployment user.
By default, authentication tokens have a one-hour lifetime. With the Override default
expiry
permission set, you can change the lifetime of the token to a
duration better suited for a long-running, automated process.
~/.puppetlabs/token
. To view the token, run
puppet-access show
.Deploy your code
Use the command line to trigger Code Manager after making changes to your Puppetfile.
puppet-code deploy --all
--wait
.
--wait
flag returns
results after the deployment is finished. Use the command puppet-code deploy
<ENVIRONMENT>
to deploy code to only a specific environment. You can
also deploy code using a webhook or custom scripts.