language-puppet: Tools to parse and evaluate the Puppet DSL.

[ bsd3, library, program, system ] [ Propose Tags ]

This is a set of tools that is supposed to fill all your Puppet needs : syntax checks, catalog compilation, PuppetDB queries, simulation of complex interactions between nodes, Puppet master replacement, and more !


[Skip to Readme]
Versions [faq] 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.7.2, 0.1.8.0, 0.2.0, 0.2.0.1, 0.2.0.2, 0.2.2.0, 0.3.0.0, 0.3.1.0, 0.3.2, 0.4.0, 0.4.2, 0.10.0, 0.10.1, 0.10.2, 0.10.3, 0.10.4, 0.10.5, 0.10.6, 0.11.0, 0.11.1, 0.11.1.1, 0.12.0, 0.12.1, 0.12.2, 0.12.3, 0.13.0, 0.14.0, 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.1.1.1, 1.1.1.2, 1.1.3, 1.1.3.1, 1.1.4, 1.1.4.1, 1.1.5, 1.1.5.1, 1.2, 1.3, 1.3.1, 1.3.1.1, 1.3.2, 1.3.2.1, 1.3.3, 1.3.4, 1.3.4.1, 1.3.5, 1.3.5.1, 1.3.6, 1.3.7, 1.3.8, 1.3.8.1, 1.3.9, 1.3.10, 1.3.11, 1.3.12, 1.3.12.1, 1.3.13, 1.3.14, 1.3.15, 1.3.16, 1.3.17, 1.3.18, 1.3.18.1, 1.3.19, 1.3.19.1, 1.3.20, 1.3.20.1, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5
Change log CHANGELOG
Dependencies aeson (>=0.8), ansi-wl-pprint (>=0.6.8), async, attoparsec (>=0.12), base (>=4.9 && <5), base16-bytestring (==0.1.*), bytestring, case-insensitive (==1.2.*), containers (>=0.5 && <0.7), cryptonite (>=0.6), directory (>=1.2 && <1.4), filecache (>=0.2.9 && <0.5), filepath (>=1.4), formatting, Glob, hashable (==1.2.*), hruby (>=0.3.2 && <0.4), hslogger (==1.2.*), http-api-data (>=0.2 && <0.5), http-client (>=0.4.30 && <0.7), language-puppet, lens (>=4.12 && <5), lens-aeson (>=1.0), megaparsec (==7.*), memory (>=0.7), mtl (>=2.2.1 && <2.3), operational (>=0.2.3 && <0.3), optparse-applicative, parsec (==3.1.*), parser-combinators (==1.*), pcre-utils (>=0.1.7 && <0.2), protolude (>=0.2), random, regex-pcre-builtin (>=0.94.4), scientific (>=0.2 && <0.4), servant (>=0.9 && <0.16), servant-client (>=0.9 && <0.16), split (==0.2.*), stm (>=2.4 && <2.6), strict-base-types (>=0.3), text (>=0.11), time (>=1.5 && <2), transformers (>=0.4 && <0.6), unix (==2.7.*), unordered-containers (==0.2.*), vector (>=0.10), yaml (>=0.8.31 && <0.12) [details]
License BSD-3-Clause
Author Simon Marechal
Maintainer bartavelle@gmail.com
Category System
Home page http://lpuppet.banquise.net/
Bug tracker https://github.com/bartavelle/language-puppet/issues
Source repo head: git clone git://github.com/bartavelle/language-puppet.git
Uploaded by pi3r at Wed Apr 17 19:09:37 UTC 2019
Distributions LTSHaskell:1.4.4, NixOS:1.4.5
Executables pdbquery, yera, puppetresources
Downloads 25293 total (1441 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user [build log]
All reported builds failed as of 2019-04-17 [all 2 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for language-puppet-1.4.4

[back to package description]

language puppet lts nightly Build Status cachix cachix orange

A library to work with Puppet manifests, test them and eventually replace everything ruby.

Install

Install with stack:

stack install language-puppet

Install with nix:

nix-env -i -f https://github.com/bartavelle/language-puppet/tarball/v1.4.3

(replace 1.4.3 with any commit ref or tag).

Build from sources:

git clone https://github.com/bartavelle/language-puppet.git
cd language-puppet
# Using nix
nix build
# Using stack
ln -s stack-10.yaml stack.yaml
stack build

Puppetresources

Basic usage

puppetresources --puppetdir /where/your/puppet/files/are --node node.name.com

The puppetresources command is a command line utility that let you interactively compute catalogs on your local computer. It is much faster than its ruby counterpart, and has been designed for giving assistance to the Puppet catalog writer.

There are 4 different modes:

  • --node will display all resources on screen in a nice user-friendly colored fashion.

  • --all displays statitics and optionally shows dead code.

  • --parse only goes as far as parsing. No interpretation.

  • --showcontent to display file content.

Catalog is not computed exactly the same way Puppet does. Some good practices are enforced. A strict and more permissive mode are provided.

Command line arguments

  • -p or --puppetdir This argument is mandatory except in parse mode. It must point to the base of the puppet directory (the directory that contains the modules and manifests directories).

  • -o or --node Enable the node mode. This let you specify the name of the node you wish to compute the catalog for.

  • -a or --all Enable the stats mode. If you specify allnodes it will compute the catalogs for all nodes that are specified in site.pp (this will not work for regexp-specified or the default nodes). You can also specify a list of nodes separated by a comma.

    Combined with --deadcode, it will display the list of puppet files that have not been used.

    This is useful as automated tests, to check a change didn’t break something. You might want to run this option with +RTS -N.

  • -t or --type Filters the resources of the resulting catalog by type. Using PCRE regex is supported.

  • -n or --name Filters the resources of the resulting catalog by name. Using PCRE regex is supported.

  • -c or --showcontent If -n is the exact name of a file type resource defined in the catalog, this will display the file content nicely. Useful for debugging templates.

    Example: puppetresources -p . -o mynodename -n '/etc/motd' --showcontent

  • --loglevel or -v Possible values are : DEBUG, INFO, NOTICE, WARNING, ERROR

  • --pdburl Expects the url of a live PuppetDB.

  • --pdbfile Expects a path to a fake PuppetDB, represented as a YAML file on disk. This option is pretty slow but can be invaluable to test exported resources tricks.

  • --hiera Expects the path to the hiera.yaml file.

  • --ignoredmodules Expects a list of comma-separated modules. The interpreter will not try to parse and evaluate the defined types and classes from this module. This is useful for using modules that use bad practices forbidden by puppetresources.

  • --commitdb When this flag is set, exported resources, catalogs and facts are saved in the PuppetDB. This is useful in conjunction with --pdbfile.

  • --checkExported When this flag is set, exported resources are saved in the PuppetDB. This is useful in conjunction with --pdbfile.

  • -j or --JSON Displays the catalog as a Puppet-compatible JSON file, that can then be used with puppet apply.

  • --strict Enable strict check. Strict is less permissive than vanilla Puppet. It is meant to prevent some pitfalls by enforcing good practices. For instance it refuses to

    • silently ignore/convert undef variables

    • lookup an hash with an unknown key and return undef.

  • --noextratests Disable the extra tests from Puppet.OptionalTests.

  • --parse Enable parse mode. Specify the puppet file to be parsed. Variables are not resolved. No interpretation.

  • --version Output version information and exist.

Settings defaults using a yaml file

Defaults for some of these options can be set using a /yourworkingdirectory/tests/defaults.yaml file. For instance OptionalTests is checking that all users and groups are known. Because some of these users and groups might be defined outside puppet, a list of known ones is used internally. This can be overridden in that file using the key knownusers and knowngroups.

Please look at the template file for a list of possible defaults.

pdbQuery

The pdbquery command will work with different implementations of PuppetDB (the official one with its HTTP API, the file-based backend and dummy ones). It can be used to:

  • export data from production PuppetDB to a file (in order to debug some issue with `puppetresources**).
  • query a Puppetdb

Command line arguments

  • -l or --location The URL of the PuppetDB when working with a remote PuppetDB, a file path when working with the file-based test implementation.

  • -t or --pdbtype The type of PuppetDB to work with:

    • dummy: a dummy PuppetDB.

    • remote: a "real" PuppetDB, accessed by its HTTP API.

    • test: a file-based backend emulating a PuppetDB.

  • facts Output facts for a specific node (json)

  • nodes Output all nodes (json)

  • resources Output all resources for a specific node (json)

  • dumpfacts Dump all facts to /tmp/allfacts.yaml.

  • snapshot Create a test DB from the current DB

  • addfacts Adds facts to the test DB for the given node name, if they are not already defined.

  • --version Output version information and exit.

Supported features

  • Supported version puppet 4 is mostly supported. Please look at the list of issues for details.

  • Custom ruby functions The tool might bark when resolving custom ruby functions. These function can easily be mocked or implemented in Haskell if necessary.

  • Puppet functions

    • the require function is not supported (see issue #17)

    • the deprecated import function is not supported

    • the deprecated node inheritance feature is not supported

  • OS Linux is the default OS. The tool has also been successfully installed and used on OS X. Windows is not supported.