The puppet-code command allows you to trigger Code Manager from the command line to deploy your environments.

Installing and configuring puppet-code

PE automatically installs and configures the puppet-code command on your masters as part of the included PE client tools package. You can also set up puppet-code on an agent node or on a workstation, customize configuration for different users, or change the configuration settings.

The global configuration settings for Linux and macOS systems are in a JSON file at /etc/puppetlabs/client-tools/puppet-code.conf. The default configuration file looks something like:

On a PE-managed machine, Puppet manages this file for you. Do not manually edit this file, because Puppet will overwrite your new values the next time it runs.

Additionally, you can set up puppet-code on an agent node or on a workstation not managed by PE. And on any machine, you can set up user-specific config files. For instructions, see the related topic about advanced configuration of puppet-code.

You can also override existing configuration settings on a case-by-case basis on the command line. When you deploy environments with the puppet-code deploy command, you can specify either an alternative config file or particular config settings directly in the command. For examples, see the related topic about deploying environments with puppet code.

Windows paths

The global puppet-code configuration file on Windows systems is located at C:\ProgramData\PuppetLabs\client-tools\puppet-code.conf.

Configuration precedence and puppet-code

There are several ways to configure puppet-code, but some configuration methods take precedence over others.

If no other configuration is specified, puppet-code uses the settings in the global configuration file. User-specific configuration files override the global configuration file.

If you specify a configuration file on the command line, Puppet temporarily uses that configuration file only and does not read the global or user-specific config files at all.

Finally, if you specify individual configuration options directly on the command line, those options temporarily take precedence over any configuration file settings.

Deploying environments with puppet-code

To deploy environments with the puppet-code command, use the deploy action, either with the name of a single environment or with the --all flag.

The deploy action deploys the environments, but returns only deployment queuing results by default. To view the results of the deployment itself, add the --wait flag.

The --wait flag deploys the specified environments, waits for file sync to complete code deployment to the live code directory and all compile masters, and then returns results. In deployments that are geographically dispersed or have a large quantity of environments, completing code deployment can take up to several minutes.

The resulting message includes the deployment signature, which is the commit SHA of the control repo used to deploy the environment. The output also includes two other SHAs that indicate that file sync is aware that the environment has been newly deployed to the code staging directory.

To temporarily override default, global, and user-specific configuration settings, specify the following configuration options on the command line:

--cacert

--token-file, -t

--service-url

Alternately, you can specify a custom puppet-code.conf configuration file by using the --config-file option.

Running puppet-code on Windows

If you're running these commands from a managed or non-managed Windows workstation, you must specify the full path to the command.

This example deploys 'mytestenvironment' using global or user-specific config settings (if set), except for --service-url, for which it uses the value specified on the command line ("https://puppet.example.com:8170/code-manager").

Advanced puppet-code configuration

You can set up the puppet-code command on an agent node or on a workstation not managed by PE. And on any machine, you can set up user-specific config files.

You can set up the puppet-code command on an agent node or on a workstation not managed by PE. And on any machine, you can set up user-specific config files.

The puppet-code.conf file is a JSON configuration file for the puppet-code command. For Linux or Mac OS X operating systems, it looks something like: