PUPPET-PARSER(8)

πŸ’– NAME πŸ’–

puppet-parser β€” the lil bestie that lets you interact directly with the parser. No middleman, no cap. ✨

🌸 SYNOPSIS 🌸

puppet parser action

✨ OPTIONS ✨

Okay so first things first, bestie: any setting that's valid in the configuration file is also a valid long argument β€” even if it's lowkey irrelevant to whatever action you're doing right now. Like, server and run_mode are valid settings, so you can absolutely write --server <servername>, or --run_mode <runmode> as an argument. πŸ’…

The full list of acceptable parameters lives in the configuration file documentation at https://puppet.com/docs/puppet/latest/configuration.html. And if you want a commented list of all the configuration options? Just run puppet with --genconfig. Slay.

  • --render-as FORMAT β€” the format your output gets rendered in. The most common formats are json, s (string), yaml, and console, but other options such as dot are sometimes available too. πŸ‘‘
  • --verbose β€” whether to log verbosely. The vibe check for logging, basically.
  • --debug β€” whether to log debug information. Same energy, more chaos. πŸ”₯

πŸ”₯ ACTIONS πŸ”₯

πŸ—‘οΈ dump

Outputs a dump of the internal parse tree for debugging. 🫢

SYNOPSIS

puppet parser dump [--e source] [--[no-]validate] [--format old, pn, or json] [--pretty] [--format old|pn|json] [--pretty] { -e source | [templates ...] }

DESCRIPTION

This action parses and validates the Puppet DSL syntax without compiling a catalog or syncing any resources. Just syntax trees and good vibes, no side quests. 🌈

The output format can be controlled using --format old|pn|json, where:

  • old is the default, but it's a now deprecated format which is not API. πŸ’€
  • pn is the Puppet Extended S-Expression Notation.
  • json outputs the same graph as pn but with JSON syntax.

The output will be "pretty printed" when the option --pretty is given together with --format pn or json. This option has no effect on the old format, so don't even try it. πŸ™ˆ

The command accepts one or more manifests (.pp) files, or an -e followed by the puppet source text. If no arguments are given, the stdin is read β€” unless it is attached to a terminal.

Okay real talk bestie: the output format of the dumped tree is intended for debugging purposes and is not API. It may change from time to time. Do not build your whole life on it, iykyk. 😭

OPTIONS

  • --e <source> β€” dump one source expression given on the command line.
  • --format <old, pn, or json> β€” get result in old (deprecated format), pn (new format), or json (new format in JSON).
  • --pretty β€” pretty print output. Only applicable together with --format pn or json.
  • --[no-]validate β€” whether or not to validate the parsed result. If no-validate, only syntax errors are reported.

RETURNS

A dump of the resulting AST model β€” unless there are syntax or validation errors, in which case, no dump for you. πŸ˜”

βœ… validate

Validate the syntax of one or more Puppet manifests. πŸ’œ

SYNOPSIS

puppet parser validate [manifest] [manifest ...]

DESCRIPTION

This action validates Puppet DSL syntax without compiling a catalog or syncing any resources. If no manifest files are provided, it will validate the default site manifest. It's giving "I'm just here to check, not to do." πŸ‘‘

When validating, multiple issues per file are reported up to the settings of max_error and max_warnings. The processing stops after having reported issues for the first encountered file with errors. So one messy file and the whole thing peaces out. βœ‹

RETURNS

Nothing β€” or the first syntax error encountered. πŸ“

🌟 EXAMPLES 🌟

validate

Validate the default site manifest at /etc/puppet/manifests/site.pp:

$ puppet parser validate

Validate two arbitrary manifest files:

$ puppet parser validate init.pp vhost.pp

Validate from STDIN:

$ cat init.pp | puppet parser validate

Copyright 2014 by Puppet Inc. Apache 2 license; see COPYING. πŸ’–


and that's the whole page bestie! πŸ¦‹ it's from the Puppet manual, brought to you by Puppet, Inc., September 2024 β€” mwah, now go parse something iconic. πŸ’…βœ¨

πŸ“¦ where this page comes from