puppet.run
The cluster and skip_hooks parameters, post-run hooks, and the current_execution.log and last_execution.log output files require RVC version 3.13.0 or later.
Runs the Puppet agent on the node. The request returns immediately, and progress is streamed until the run completes. While the run is in progress, its output is written to /var/log/puppetlabs/current_execution.log; once the run completes, the file is renamed to /var/log/puppetlabs/last_execution.log. Only the most recent run is kept.
A run is carried out by a process separate from the RVC server, so stopping, restarting, or upgrading the RVC server while a run is in progress does not interrupt it. The run completes normally and its output is still saved to last_execution.log.
If Puppet is disabled on the node, the run is refused rather than started. The response names the reason the agent was disabled and the user who disabled it, the CLI exits with code 1, and the times of the last and next runs are left unchanged. Use force to run anyway, which enables Puppet, runs it, and disables it again afterward with the original user and reason. To check the current state first, see puppet.status.
Only one run can be pending or in progress on a node at a time. While a run is waiting to start or running, another request is refused with Puppet busy running since <time> ago. and the CLI exits with code 1.
In RVC 3.13.0, the CLI exits with code 0 when a run completes, including when Puppet applied changes. The Puppet exit code is reported in the last line of the output, for example Puppet applied changes (exit code 2). In earlier versions, the CLI exits with the Puppet exit code, so a run that applied changes exits with code 2.
JSON-RPC Request
{"jsonrpc":"2.0","id":1,"method":"puppet.run","params":{"environment":"<environment>","server":"<puppet_server>","ca_server":"<ca_server>","notify_uri":"<notify_uri>","noop":"<boolean>","force":"<boolean>","random_wait":"<seconds>","cluster":"<cluster_role>","skip_hooks":"<boolean>"}}
Request Parameters
| Argument | Type | Description | Required | Default |
|---|---|---|---|---|
environment | String | The environment in which Puppet will run. By default, RVC uses the Puppet Environment defined in SC//Reliant™ Platform Manager so this parameter is only used to override that value. | No | nil |
server | String | The primary Puppet server to which the Puppet agent should connect. By default, RVC uses the Puppet Server defined in SC//Reliant Platform Manager so this parameter is only used to override that value. | No | nil |
ca_server | String | The server to use for certificate authority requests. By default, RVC uses the Puppet certificate server defined in SC//Reliant Platform Manager so this parameter is only used to override that value. | No | nil |
noop | Boolean | Whether to apply catalogs in noop mode, which allows Puppet to partially simulate a normal run. | No | false |
force | Boolean | Whether to force a Puppet run even if it is disabled. This flag will enable Puppet, start a Puppet run, and then disable Puppet again with the original user and reason. | No | false |
random_wait | Integer | The maximum random wait, in seconds, before Puppet runs. When this parameter is omitted, the run starts immediately. When it is set to 0, RVC waits a random time up to the puppet_max_wait value in the RVC configuration file, which is 300 seconds by default. To start a run immediately, omit this parameter rather than setting it to 0. | No | nil |
cluster | String | Determines cluster-wide orchestration for the run. Accepted values are none, primary, and secondary. Passing --cluster without a value on the CLI is equivalent to primary. See Cluster orchestration. | No | none |
notify_uri | String | Where to send the Puppet run progress updates. | No | nil |
skip_hooks | Boolean | Whether to skip the post-run hooks for this run only. See Post-run hooks. | No | false |
Cluster orchestration
Without cluster, or with cluster set to none, Puppet runs on the local node only, including on a node that is part of a cluster.
On a cluster, primary runs Puppet on the primary node first and then on the secondary node, and secondary runs it on the secondary node first and then on the primary node. The run can be started from either node. When it is started from the node that runs second, that node waits until the first node finishes.
- Pre-flight check: If Puppet is disabled on the other node, RVC warns before the first run starts that the other node will not run.
- Success: If the first run succeeds (Puppet exit code
0, or2when changes were applied), the run on the second node starts automatically. - Failure: If the first run fails (exit code greater than
2), the run on the second node is skipped so that a failed configuration is not applied to both nodes. - Busy or unreachable node: If the other node is already running Puppet or cannot be reached, the orchestration stops with a message rather than waiting.
In RVC 3.13.0, some cluster orchestration messages are not shown and two of the safeguards above do not take effect:
- The progress messages, such as
Puppet run requested on primary...andTriggering puppet run on the secondary..., are not printed. The orchestration itself still runs. - When the other node is already running Puppet, the orchestration waits for that run to finish and then continues, instead of stopping with a
Puppet busymessage. Withsecondary, the run on the second node is not started. - When the other node does not respond, the orchestration waits indefinitely.
- No warning is shown before the run when Puppet is disabled on the other node. The message that the node was skipped appears only after the first run completes.
Post-run hooks
After a Puppet run finishes, RVC runs any post-run hook scripts that are installed on the node and reports the result of each. Hooks run after both successful and failed runs, but not after a run stopped with puppet.stop. A failing hook does not change the exit code of the Puppet run. The hook results are streamed with the run output and added to last_execution.log, followed by a summary line. To run the hooks on demand without a Puppet run, see puppet.hooks.
JSON-RPC Response
{
"jsonrpc": "2.0",
"id": 1,
"result": "<result_message>"
}
RVC CLI Example
rvc puppet run
Response
↻ Executing method 'puppet.run' as external process with PID 28860 ...
Running puppet...
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Notice: Requesting catalog from puppet:8140
Notice: Applied catalog in 18.89 seconds
Running post-run hook: 10-hello.sh...
Hook 10-hello.sh succeeded.
hook ok
Running post-run hook: 20-fail.sh...
Hook 20-fail.sh failed (exit code 1).
about to fail
Post-run hooks: 1 passed, 1 failed (20-fail.sh)
Puppet run took less than a minute. Puppet applied changes (exit code 2). Output saved to /var/log/puppetlabs/last_execution.log.
Output when Puppet is disabled on the node:
Puppet agent is currently disabled and will not run until it is manually enabled. Reason: <text_describing_reason>. Disabled by: test.user.
Output with --force when Puppet is disabled on the node:
Enabling puppet...
Running puppet...
Info: Using environment 'production'
...
Notice: Applied catalog in 176.07 seconds
Disabling puppet...
Puppet run took 4 minutes. Puppet applied changes (exit code 2). Output saved to /var/log/puppetlabs/last_execution.log.
Output with --random-wait, where the run waits a random time before it starts:
↻ Executing method 'puppet.run' as external process with PID 28860 ...
Waiting 85 seconds before running puppet...
Running puppet...
...
Output when a run is already pending or in progress:
Puppet busy running since less than 5 seconds ago.