Configure Code Manager
To configure Code Manager, first enable Code Manager in Puppet Enterprise (PE), then set up authentication, and test the communication between the control repository and Code Manager.
Complete the following steps to enable and configure Code Manager.
Upgrade from r10k to Code Manager
To upgrade from r10k to Code Manager, you must disable the previous r10k installation.
You must complete the following pre-requisites when you upgrade from r10k to Code Manager:
If you used any previous versions of r10k:
zack-r10k
module.When you use Code Manager, it runs r10k in the background. You cannot directly interact with
r10k or use the zack-r10k
module.
Enable Code Manager
Enable Code Manager to connect your primary server to your Git repository.
/etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa
. Set up authentication for Code Manager
To securely deploy environments, Code Manager needs an authentication token for both authentication and authorization.
To generate a token for Code Manager:
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
.
Test the control repo
To make sure that Code Manager can connect to the control repo, test the connection to the repository.
puppet-code deploy --dry-run
.
-
If the control repo is set up properly, this command fetches and displays the number of environments in the control repo.
-
If an environment is not set up properly or causes an error, it does not appear in the returned list. Check the Puppet Server log for details about the errors.
Test Code Manager
Test Code Manager by deploying a single test environment.
puppet-code
deploy my_test_environment --wait
This deploys the test environment, and then returns deployment results with the SHA (a checksum for the content stored) for the control repository commit.
If the environment deploys and returns the deployment results, Code Manager is correctly configured.
If the deployment does not work, review the configuration steps, or refer to troubleshooting.ditamap for help.
After Code Manager is fully enabled and configured, you can trigger Code Manager to deploy your environments.
There are several ways to trigger deployments, depending on your needs.
Code Manager settings
After Code Manager is configured, you can adjust its
settings in the PE Master node group, in the puppet_enterprise::profile::master
class.
These options are required for Code Manager to work, unless otherwise noted.
-
puppet_enterprise::profile::master::code_manager_auto_configure
- Specifies whether to autoconfigure Code Manager and file sync.
puppet_enterprise::profile::master::r10k_remote
- The location, as a valid URL, for your Git control repository.
-
puppet_enterprise::profile::master::r10k_private_key
- The path to the file containing the private key used to access all Git repositories. Required when using the SSH protocol; optional in all other cases.
-
puppet_enterprise::profile::master::r10k_proxy
- Optional proxy used by r10k when accessing the Forge. If empty, no proxy settings are used.
-
puppet_enterprise::profile::master::r10k_trace
- Configuration option that includes the r10k stacktrace in the error
output of failed deployments when the value is
true
. -
puppet_enterprise::profile::master::versioned_deploys
- Optional setting that specifies whether code is updated in versioned code directories instead of blocking requests and overwriting the live code directory.
-
puppet_enterprise::master::environment_timeout
- Specifies whether and how long environments are cached, which can
significantly reduce CPU usage of your Puppet Server. You can specify any of these values:
-
0
– no caching -
unlimited
– all environments are cached forever - a length of time for environments to be cached, for example
30m
-
-
puppet_enterprise::master::environment_timeout_mode
- Indicates whether a length of time specified by the
environment_timeout
begins when the environment is created (from_created
) or when it's last used (from_last_used
).
environment_timeout_mode
to from_last_used
and environment_timeout
to 30m
. To further customize your Code Manager configuration with Hiera, see Customize Code Manager configuration in Hiera.