2013-09-08 02:56:00 -04:00
|
|
|
---
|
2017-06-14 21:04:16 -04:00
|
|
|
description: |
|
|
|
|
The masterless Puppet Packer provisioner configures Puppet to run on the
|
2018-10-26 20:02:51 -04:00
|
|
|
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. Puppet is run in masterless mode, meaning it never communicates
|
|
|
|
to a Puppet master.
|
2015-07-22 22:31:00 -04:00
|
|
|
layout: docs
|
2017-06-14 21:04:16 -04:00
|
|
|
page_title: 'Puppet Masterless - Provisioners'
|
|
|
|
sidebar_current: 'docs-provisioners-puppet-masterless'
|
2017-03-25 18:13:52 -04:00
|
|
|
---
|
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.
|
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
-> **Note:** Puppet will *not* be installed automatically by this
|
2015-07-22 22:31:00 -04:00
|
|
|
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
|
|
|
|
2020-03-12 10:05:08 -04:00
|
|
|
```json
|
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:
|
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
- `manifest_file` (string) - This is either a path to a puppet manifest
|
2018-10-26 20:02:51 -04:00
|
|
|
(`.pp` file) *or* a directory containing multiple manifests that puppet
|
|
|
|
will apply (the ["main
|
2015-07-22 23:25:58 -04:00
|
|
|
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:
|
|
|
|
|
2020-02-20 05:05:27 -05:00
|
|
|
- `execute_command` (string) - The command-line to execute Puppet. This is a
|
|
|
|
[template engine](/docs/templates/engine.html). Therefore, you
|
|
|
|
may use user variables and template functions in this field. In addition,
|
|
|
|
you may use the following extra variables:
|
|
|
|
* FacterVars: Additional facts to set when executing Puppet, joined for
|
|
|
|
use in a command. This is internal and not settable by the user.
|
|
|
|
* HieraConfigPath: Path to a hiera configuration file to upload and use;
|
|
|
|
set in the template option hiera_config_path
|
|
|
|
* ManifestDir: The directory of the manifest file on the remote machine.
|
|
|
|
* ManifestFile: The manifest file on the remote machine.
|
|
|
|
* ModulePath: The module_paths, combined into one path variable.
|
|
|
|
* ModulePathJoiner: A colon `:` on posix systems and a semicolon `;` on
|
|
|
|
Windows.
|
|
|
|
* PuppetBinDir: The directory that the Puppet binary is in.
|
|
|
|
* Sudo: Returns false when PreventSudo is set, and true when it is not.
|
|
|
|
* WorkingDir: The value provided in the `working_directory` option.
|
|
|
|
See below for `execute_command`'s default value.
|
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
|
|
|
|
- `extra_arguments` (array of strings) - Additional options to pass to the
|
2020-02-20 05:05:27 -05:00
|
|
|
Puppet command. This allows for customization of
|
2018-10-26 20:02:51 -04:00
|
|
|
`execute_command` without having to completely replace or subsume its
|
|
|
|
contents, making forward-compatible customizations much easier to maintain.
|
|
|
|
|
|
|
|
This string is lazy-evaluated so one can incorporate logic driven by
|
|
|
|
template variables as well as private elements of ExecuteTemplate (see
|
|
|
|
source: provisioner/puppet-masterless/provisioner.go).
|
|
|
|
|
|
|
|
[
|
|
|
|
{{if ne "{{user environment}}" ""}}--environment={{user environment}}{{end}},
|
|
|
|
{{if ne ".ModulePath" ""}}--modulepath="{{.ModulePath}}{{.ModulePathJoiner}}$(puppet config print {{if ne "{{user `environment`}}" ""}}--environment={{user `environment`}}{{end}} modulepath)"{{end}}
|
|
|
|
]
|
2015-11-03 13:55:40 -05:00
|
|
|
|
2018-05-08 12:29:13 -04:00
|
|
|
- `facter` (object of key:value strings) - Additional
|
2019-01-11 17:06:15 -05:00
|
|
|
[facts](https://docs.puppet.com/facter/) to make available to the Puppet
|
|
|
|
run.
|
2015-07-22 23:25:58 -04:00
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
- `guest_os_type` (string) - The remote host's OS type ('windows' or 'unix')
|
|
|
|
to tailor command-line and path separators. (default: unix).
|
2017-10-17 11:25:40 -04:00
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
- `hiera_config_path` (string) - Local path to self-contained Hiera data to
|
|
|
|
be uploaded. NOTE: If you need data directories they must be previously
|
|
|
|
transferred with a File provisioner.
|
2015-07-22 23:25:58 -04:00
|
|
|
|
2018-05-08 12:29:13 -04:00
|
|
|
- `ignore_exit_codes` (boolean) - If true, Packer will ignore failures.
|
2016-03-13 23:39:29 -04:00
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
- `manifest_dir` (string) - Local directory with manifests to be uploaded.
|
|
|
|
This is useful if your main manifest uses imports, but the directory might
|
|
|
|
not contain the `manifest_file` itself.
|
2015-07-22 23:25:58 -04:00
|
|
|
|
2019-01-11 17:06:15 -05:00
|
|
|
\~> `manifest_dir` is passed to Puppet as `--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.
|
2015-07-22 23:25:58 -04:00
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
- `module_paths` (array of strings) - Array of local module directories to be
|
|
|
|
uploaded.
|
2018-05-08 12:29:13 -04:00
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
- `prevent_sudo` (boolean) - On Unix platforms Puppet is typically invoked
|
|
|
|
with `sudo`. If true, it will be omitted. (default: false)
|
2018-05-08 12:29:13 -04:00
|
|
|
|
|
|
|
- `puppet_bin_dir` (string) - Path to the Puppet binary. Ideally the program
|
2018-10-26 20:02:51 -04:00
|
|
|
should be on the system (unix: `$PATH`, windows: `%PATH%`), but some
|
|
|
|
builders (eg. Docker) do not run profile-setup scripts and therefore PATH
|
2018-12-10 05:26:28 -05:00
|
|
|
might be empty or minimal. On Windows, spaces should be `^`-escaped, i.e.
|
|
|
|
`c:/program^ files/puppet^ labs/puppet/bin`.
|
2018-05-08 12:29:13 -04:00
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
- `staging_directory` (string) - Directory to where uploaded files will be
|
|
|
|
placed (unix: "/tmp/packer-puppet-masterless", windows:
|
|
|
|
"%SYSTEMROOT%/Temp/packer-puppet-masterless"). It doesn't need to
|
|
|
|
pre-exist, but the parent must have permissions sufficient for the account
|
|
|
|
Packer connects as to create directories and write files. Use a Shell
|
|
|
|
provisioner to prepare the way if needed.
|
2018-05-08 12:29:13 -04:00
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
- `working_directory` (string) - Directory from which `execute_command` will
|
|
|
|
be run. If using Hiera files with relative paths, this option can be
|
|
|
|
helpful. (default: `staging_directory`)
|
2015-01-10 18:25:48 -05:00
|
|
|
|
2018-12-07 10:36:30 -05:00
|
|
|
- `elevated_user` and `elevated_password` (string) - If specified, Puppet
|
|
|
|
will be run with elevated privileges using the given Windows user. See the
|
2018-12-13 05:32:36 -05:00
|
|
|
[powershell](/docs/provisioners/powershell.html) provisioner for the full
|
2020-02-20 05:05:27 -05:00
|
|
|
details. This is a [template engine](/docs/templates/engine.html).
|
|
|
|
Therefore, you may use user variables and template functions in this
|
|
|
|
field, including ```{{ build `Password`}}``` to use the password being used
|
|
|
|
by the communicator to connect to your instance.
|
2018-12-07 10:36:30 -05:00
|
|
|
|
2019-04-08 10:05:04 -04:00
|
|
|
<%= partial "partials/provisioners/common-config" %>
|
|
|
|
|
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
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
cd {{.WorkingDir}} &&
|
|
|
|
{{if ne .FacterVars ""}}{{.FacterVars}} {{end}}
|
|
|
|
{{if .Sudo}}sudo -E {{end}}
|
|
|
|
{{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}}
|
|
|
|
puppet apply --detailed-exitcodes
|
|
|
|
{{if .Debug}}--debug {{end}}
|
|
|
|
{{if ne .ModulePath ""}}--modulepath='{{.ModulePath}}' {{end}}
|
|
|
|
{{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}}
|
|
|
|
{{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}}
|
|
|
|
{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}
|
|
|
|
{{.ManifestFile}}
|
2017-01-13 03:11:18 -05:00
|
|
|
|
2017-08-14 23:01:24 -04:00
|
|
|
The following command is used if guest OS type is windows:
|
2017-01-13 03:11:18 -05:00
|
|
|
|
2018-10-26 20:02:51 -04:00
|
|
|
cd {{.WorkingDir}} &&
|
|
|
|
{{if ne .FacterVars ""}}{{.FacterVars}} && {{end}}
|
|
|
|
{{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}}
|
|
|
|
puppet apply --detailed-exitcodes
|
|
|
|
{{if .Debug}}--debug {{end}}
|
|
|
|
{{if ne .ModulePath ""}}--modulepath='{{.ModulePath}}' {{end}}
|
|
|
|
{{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}}
|
|
|
|
{{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}}
|
|
|
|
{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}
|
|
|
|
{{.ManifestFile}}
|
2013-09-08 02:56:00 -04:00
|
|
|
|
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:
|
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
- `packer_build_name` is set to the name of the build that Packer is running.
|
2015-07-22 23:25:58 -04:00
|
|
|
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
|
|
|
|
2018-10-26 20:02:51 -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.
|