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 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. It isn't required to use PE, but it is helpful for ensuring Puppet syncs code to your masters and all your server run new code at the same time.
Create a control repo from the Puppet template
To create a control 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 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.
Set up a private SSH key so that your master can identify itself to your Git host.
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
To enable Code Manager set parameters in the console.
Set up authentication for Code Manager
To securely deploy environments, Code Manager needs an authentication token for both authentication and authorization.
If you would like to use PE client tools, configure these now. PE client tools let you access PE services from a workstation that is not necessarily managed by Puppet. They come pre-installed on your master, but you need to configure them by creating a configuration file. See Configuring PE client tools for more information.
To generate a token for Code Manager, first assign a user to the deployment role, and then request an authentication token.
Assign a user to the deployment role
To request an authentication token, you must first assign a user the correct permissions with role-based access control (RBAC).
- In the console, create a deployment user. We recommend that you create a dedicated deployment user for Code Manager use.
- Add the deployment user to the Code Deployers role. This role is automatically created on install, with default permissions for code deployment and token lifetime management.
- Create a password by clicking Generate Password.
Next, request the authentication token.
Request an authentication token for deployments
Request an authentication token for the deployment user to enable secure deployment of your code.
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.
Generate the authentication token using
the puppet-access
command.
The generated token is stored in a file for later use. The default location for storing the token
is ~/.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.