puppet-masterless

This is a small tool designed to help you use Puppet without using a Puppet Master. It packages a Puppet project as a self-contained shell script and optionally executes it on a remote machine via SSH. You can think of it like a remote version of the puppet-apply command[^1].

[^1]: In fact, running puppet-apply is exactly what it does in the end.

Installation

From RubyGems.org

To install from RubyGems.org just run:

gem install puppet-masterless

From Source

The program is a single Ruby file. To install it from source, simply put it somewhere on your PATH and make sure it's executable:

install -m 755 src/puppet-masterless /usr/local/bin/puppet-masterless

You can also install its man page, if desired:

install -m 644 man/puppet-masterless.1 /usr/local/share/man/man1/puppet-masterless.1

Alternatively, you can use Rake to build and install the program as a Gem:

rake install:local

Usage

Quick Start

To package a project, use the package command:

puppet-masterless package confdir <confdir>

To apply a project to a remote host, use the apply command:

puppet-masterless apply confdir <confdir> to <hostname>

In both situations, <confdir> should be the base directory of your Puppet project. Refer to Puppet's documentation for details about how this directory should be organised.

Options

The program accepts arguments according to a very simple command line grammar. To see a summary of the available options and what they control, run puppet-masterless without any arguments. For full documentation, refer to its man page[^2] or help text (accessed via puppet-masterless help).

[^2]: You can view a Gem's man page by installing the gem-man extension and running gem man <gem>.

Project Layout

It's assumed that your Puppet project is laid out something like this:

<confdir>
├── puppet.conf
├── hiera.yaml
├── data
│   └── ...
├── manifests
│   └── ...
└── modules
    └── ...

All of these paths can be overridden by command line arguments, but the tool will work best if you use a project structure similar to this one.

Most importantly, all paths in your Hiera configuration should be relative to the project's root, so that puppet-apply will only consult Hiera data that's included in the package. In Hiera 5 this is usually the case by default, since paths are considered relative to your hiera.yaml:

---
version: 5
defaults:
  datadir: data
  data_hash: yaml_data
hierarchy:
  - name: Common data
    path: common.yaml

In Hiera 3, this must be done manually. The following hiera.yaml illustrates one way to do this, by explicitly setting :datadir to a path under your project's confdir:

---
:backends:
  - yaml
:yaml:
  :datadir: "%{settings::confdir}/data"

Contributing

  1. Fork it from https://gitlab.com/catalyst-it/puppet-masterless
  2. Create a feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a Merge Request at https://gitlab.com/catalyst-it/puppet-masterless/merge_requests