LinuxCommandLibrary

puppet-apply

Apply Puppet manifests locally

TLDR

Apply a manifest

$ puppet apply [path/to/manifest]
copy

Execute puppet code
$ puppet apply --execute [code]
copy

Use a specific module and hiera configuration file
$ puppet apply --modulepath [path/to/directory] --hiera_config [path/to/file] [path/to/manifest]
copy

SYNOPSIS

puppet-apply [options]

PARAMETERS

--debug
    Enable verbose debugging output.

--verbose
    Enable more verbose output.

--noop
    Run in 'no-op' mode, simulating changes without applying them.

--catalog
    Apply a pre-compiled catalog from a file.

--execute
    Execute a snippet of Puppet code directly.

--modulepath :
    Specify the module path (colon-separated list).

--detailed-exitcodes
    Provide more detailed exit codes to indicate the type of changes made.

--logdest
    Specify the log destination.

--apply
    Treat standard input as a manifest to be applied. Requires the `puppet` executable to be present in `$PATH`.

DESCRIPTION

The `puppet-apply` command allows you to execute Puppet manifests directly on a target system without requiring a connection to a Puppet Server. This is primarily useful for initial configuration, testing manifests before deploying them centrally, or for managing single, standalone nodes.

It compiles a catalog from a manifest (or multiple manifests) and applies that catalog using the local system's resources and configurations. It operates in a standalone manner, meaning it doesn't depend on a central server for catalog compilation or resource retrieval (other than optionally accessing external modules or resources specified in the manifest). This command is helpful in situations where network connectivity is limited or a quick application of Puppet code is needed. Changes are made to the local system based on the Puppet code provided.

CAVEATS

Using `puppet-apply` bypasses the usual centralized management provided by a Puppet Server, so changes aren't tracked centrally. It's important to carefully manage and test any manifests before applying them locally.

EXIT CODES

  • 0: No changes were made
  • 1: An error occurred
  • 2: Changes were made
  • 4: Changes were made, and a reboot is required
  • 6: Changes were made, and a reboot is required; also, some failures occurred.
For detailed exitcodes option, exitcodes 0, 1, 2, and 4 are possible. It is usually used in automated scenarios

BEST PRACTICES

Before using `puppet-apply` in a production environment, always thoroughly test your manifests using `--noop` to verify that they will have the intended effects. When possible, prefer managing systems with a Puppet Server for centralized configuration and version control.

HISTORY

The `puppet-apply` command has been part of the Puppet ecosystem since its early versions. It was created to provide a way to execute Puppet code on individual systems without requiring a centralized Puppet Server. Over time, it has been improved to support more options and features. It is still used for provisioning and testing Puppet code, when Puppet infrastructure is missing or impractical.

SEE ALSO

puppet(8), puppet-agent(8), puppet-resource(8)

Copied to clipboard