2013-09-08 02:56:00 -04:00
|
|
|
---
|
2015-07-22 22:31:00 -04:00
|
|
|
description: |
|
|
|
|
The masterless Puppet Packer provisioner configures Puppet to run on the
|
|
|
|
machines by Packer from local modules and manifest files. Modules and manifests
|
|
|
|
can be uploaded from your local machine to the remote machine or can simply use
|
|
|
|
remote paths (perhaps obtained using something like the shell provisioner).
|
|
|
|
Puppet is run in masterless mode, meaning it never communicates to a Puppet
|
|
|
|
master.
|
|
|
|
layout: docs
|
|
|
|
page_title: 'Puppet (Masterless) Provisioner'
|
|
|
|
...
|
2013-09-08 02:56:00 -04:00
|
|
|
|
|
|
|
# Puppet (Masterless) Provisioner
|
|
|
|
|
|
|
|
Type: `puppet-masterless`
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
The masterless Puppet Packer provisioner configures Puppet to run on the
|
|
|
|
machines by Packer from local modules and manifest files. Modules and manifests
|
|
|
|
can be uploaded from your local machine to the remote machine or can simply use
|
|
|
|
remote paths (perhaps obtained using something like the shell provisioner).
|
2013-09-08 02:56:00 -04:00
|
|
|
Puppet is run in masterless mode, meaning it never communicates to a Puppet
|
|
|
|
master.
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
-> **Note:** Puppet will *not* be installed automatically by this
|
|
|
|
provisioner. This provisioner expects that Puppet is already installed on the
|
|
|
|
machine. It is common practice to use the [shell
|
|
|
|
provisioner](/docs/provisioners/shell.html) before the Puppet provisioner to do
|
|
|
|
this.
|
2013-09-08 02:56:00 -04:00
|
|
|
|
|
|
|
## Basic Example
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
The example below is fully functional and expects the configured manifest file
|
2016-12-28 23:33:44 -05:00
|
|
|
to exist relative to your working directory.
|
2013-09-08 02:56:00 -04:00
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
``` {.javascript}
|
2013-09-08 02:56:00 -04:00
|
|
|
{
|
|
|
|
"type": "puppet-masterless",
|
|
|
|
"manifest_file": "site.pp"
|
|
|
|
}
|
2014-10-20 13:55:16 -04:00
|
|
|
```
|
2013-09-08 02:56:00 -04:00
|
|
|
|
|
|
|
## Configuration Reference
|
|
|
|
|
|
|
|
The reference of available configuration options is listed below.
|
|
|
|
|
|
|
|
Required parameters:
|
|
|
|
|
2015-07-22 23:25:58 -04:00
|
|
|
- `manifest_file` (string) - This is either a path to a puppet manifest
|
|
|
|
(`.pp` file) *or* a directory containing multiple manifests that puppet will
|
|
|
|
apply (the ["main
|
|
|
|
manifest"](https://docs.puppetlabs.com/puppet/latest/reference/dirs_manifest.html)).
|
|
|
|
These file(s) must exist on your local system and will be uploaded to the
|
|
|
|
remote machine.
|
2013-09-08 02:56:00 -04:00
|
|
|
|
|
|
|
Optional parameters:
|
|
|
|
|
2015-07-22 23:25:58 -04:00
|
|
|
- `execute_command` (string) - The command used to execute Puppet. This has
|
|
|
|
various [configuration template
|
|
|
|
variables](/docs/templates/configuration-templates.html) available. See
|
|
|
|
below for more information.
|
|
|
|
|
2015-11-03 17:55:03 -05:00
|
|
|
- `extra_arguments` (array of strings) - This is an array of additional options to
|
2015-11-03 13:55:40 -05:00
|
|
|
pass to the puppet command when executing puppet. This allows for
|
|
|
|
customization of the `execute_command` without having to completely replace
|
|
|
|
or include it's contents, making forward-compatible customizations much
|
|
|
|
easier.
|
|
|
|
|
2015-07-22 23:25:58 -04:00
|
|
|
- `facter` (object of key/value strings) - Additional
|
2016-01-14 15:31:19 -05:00
|
|
|
[facts](https://puppetlabs.com/facter) to make
|
2015-07-22 23:25:58 -04:00
|
|
|
available when Puppet is running.
|
|
|
|
|
|
|
|
- `hiera_config_path` (string) - The path to a local file with hiera
|
|
|
|
configuration to be uploaded to the remote machine. Hiera data directories
|
|
|
|
must be uploaded using the file provisioner separately.
|
|
|
|
|
2016-03-13 23:39:29 -04:00
|
|
|
- `ignore_exit_codes` (boolean) - If true, Packer will never consider the
|
|
|
|
provisioner a failure.
|
|
|
|
|
2015-07-22 23:25:58 -04:00
|
|
|
- `manifest_dir` (string) - The path to a local directory with manifests to be
|
|
|
|
uploaded to the remote machine. This is useful if your main manifest file
|
|
|
|
uses imports. This directory doesn't necessarily contain the
|
|
|
|
`manifest_file`. It is a separate directory that will be set as the
|
|
|
|
"manifestdir" setting on Puppet.
|
|
|
|
|
|
|
|
\~> `manifest_dir` is passed to `puppet apply` as the `--manifestdir` option.
|
|
|
|
This option was deprecated in puppet 3.6, and removed in puppet 4.0. If you have
|
|
|
|
multiple manifests you should use `manifest_file` instead.
|
|
|
|
|
2016-12-28 23:33:44 -05:00
|
|
|
- `puppet_bin_dir` (string) - The path to the directory that contains the puppet
|
|
|
|
binary for running `puppet apply`. Usually, this would be found via the `$PATH`
|
|
|
|
or `%PATH%` environment variable, but some builders (notably, the Docker one) do
|
|
|
|
not run profile-setup scripts, therefore the path is usually empty.
|
2016-10-16 16:24:56 -04:00
|
|
|
|
2015-07-22 23:25:58 -04:00
|
|
|
- `module_paths` (array of strings) - This is an array of paths to module
|
|
|
|
directories on your local filesystem. These will be uploaded to the
|
|
|
|
remote machine. By default, this is empty.
|
|
|
|
|
|
|
|
- `prevent_sudo` (boolean) - By default, the configured commands that are
|
|
|
|
executed to run Puppet are executed with `sudo`. If this is true, then the
|
|
|
|
sudo will be omitted.
|
|
|
|
|
|
|
|
- `staging_directory` (string) - This is the directory where all the
|
|
|
|
configuration of Puppet by Packer will be placed. By default this
|
|
|
|
is "/tmp/packer-puppet-masterless". This directory doesn't need to exist but
|
|
|
|
must have proper permissions so that the SSH user that Packer uses is able
|
|
|
|
to create directories and write into this folder. If the permissions are not
|
|
|
|
correct, use a shell provisioner prior to this to configure it properly.
|
|
|
|
|
|
|
|
- `working_directory` (string) - This is the directory from which the puppet
|
|
|
|
command will be run. When using hiera with a relative path, this option
|
|
|
|
allows to ensure that the paths are working properly. If not specified,
|
|
|
|
defaults to the value of specified `staging_directory` (or its default value
|
|
|
|
if not specified either).
|
2015-01-10 18:25:48 -05:00
|
|
|
|
2013-09-08 02:56:00 -04:00
|
|
|
## Execute Command
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
By default, Packer uses the following command (broken across multiple lines for
|
|
|
|
readability) to execute Puppet:
|
2013-09-08 02:56:00 -04:00
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
``` {.liquid}
|
2015-01-10 18:25:48 -05:00
|
|
|
cd {{.WorkingDir}} && \
|
2016-10-16 16:24:56 -04:00
|
|
|
{{.FacterVars}}{{if .Sudo}} sudo -E {{end}} \
|
|
|
|
{{if ne .PuppetBinDir \"\"}}{{.PuppetBinDir}}{{end}}puppet apply \
|
2013-09-08 02:56:00 -04:00
|
|
|
--verbose \
|
|
|
|
--modulepath='{{.ModulePath}}' \
|
2016-12-30 00:22:34 -05:00
|
|
|
{{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}} \
|
|
|
|
{{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}} \
|
2014-01-04 13:55:56 -05:00
|
|
|
--detailed-exitcodes \
|
2016-12-30 00:22:34 -05:00
|
|
|
{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}} \
|
2013-09-08 02:56:00 -04:00
|
|
|
{{.ManifestFile}}
|
|
|
|
```
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
This command can be customized using the `execute_command` configuration. As you
|
|
|
|
can see from the default value above, the value of this configuration can
|
|
|
|
contain various template variables, defined below:
|
2013-09-08 02:56:00 -04:00
|
|
|
|
2015-07-22 23:25:58 -04:00
|
|
|
- `WorkingDir` - The path from which Puppet will be executed.
|
|
|
|
- `FacterVars` - Shell-friendly string of environmental variables used to set
|
|
|
|
custom facts configured for this provisioner.
|
|
|
|
- `HieraConfigPath` - The path to a hiera configuration file.
|
|
|
|
- `ManifestFile` - The path on the remote machine to the manifest file for
|
|
|
|
Puppet to use.
|
|
|
|
- `ModulePath` - The paths to the module directories.
|
|
|
|
- `Sudo` - A boolean of whether to `sudo` the command or not, depending on the
|
|
|
|
value of the `prevent_sudo` configuration.
|
2015-01-27 14:11:08 -05:00
|
|
|
|
|
|
|
## Default Facts
|
|
|
|
|
|
|
|
In addition to being able to specify custom Facter facts using the `facter`
|
|
|
|
configuration, the provisioner automatically defines certain commonly useful
|
|
|
|
facts:
|
|
|
|
|
2015-07-22 23:25:58 -04:00
|
|
|
- `packer_build_name` is set to the name of the build that Packer is running.
|
|
|
|
This is most useful when Packer is making multiple builds and you want to
|
|
|
|
distinguish them in your Hiera hierarchy.
|
2015-01-27 14:11:08 -05:00
|
|
|
|
2015-07-22 23:25:58 -04:00
|
|
|
- `packer_builder_type` is the type of the builder that was used to create the
|
|
|
|
machine that Puppet is running on. This is useful if you want to run only
|
|
|
|
certain parts of your Puppet code on systems built with certain builders.
|