puppet.hooks
This method is only available when using RVC version 3.13.0 or later.
Runs the post-run hook scripts on the node immediately, without a Puppet run, and returns the result of each. The same hooks run automatically after every puppet.run unless skip_hooks is set (--skip-hooks on the CLI). The result is an empty array when no hooks are installed.
JSON-RPC Request
{"jsonrpc":"2.0","id":1,"method":"puppet.hooks"}
JSON-RPC Response
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"name": "<hook_name>",
"content": "<hook_output>"
},
{
"name": "<hook_name>",
"error": "<failure_reason_and_hook_output>"
}
]
}
Response parameters
The result contains one entry for each hook, in the order the hooks ran.
| Parameter | Type | Description |
|---|---|---|
name | String | The file name of the hook script. |
content | String | The output of the hook. Present only when the hook succeeds. |
error | String | The reason the hook failed, such as Exit code 1 or Timed out, followed by the output of the hook. Present only when the hook fails or times out. |
RVC CLI Example
rvc puppet hooks
Response
Name...: 10-hello.sh
Content: hook ok
Name.: 20-fail.sh
Error: Exit code 1
about to fail
When no hooks are installed, the CLI prints nothing and exits with code 0. With --json, the result is an empty array:
{
"jsonrpc": "2.0",
"id": 1,
"result": []
}