packer-cn/website/source/docs/provisioners/puppet-server.html.md

147 lines
5.9 KiB
Markdown
Raw Normal View History

2014-01-08 06:46:34 -05:00
---
2017-06-14 21:04:16 -04:00
description: |
2018-10-26 20:02:51 -04:00
The puppet-server Packer provisioner provisions Packer machines with Puppet by
connecting 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 Server - Provisioners'
sidebar_current: 'docs-provisioners-puppet-server'
---
2014-01-08 06:46:34 -05:00
# Puppet Server Provisioner
2014-01-08 06:46:34 -05:00
Type: `puppet-server`
2018-10-26 20:02:51 -04:00
The `puppet-server` Packer provisioner provisions Packer machines with Puppet
by connecting to a Puppet master.
2014-01-08 06:46:34 -05:00
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.
2014-01-08 06:46:34 -05:00
## Basic Example
2015-07-22 22:31:00 -04:00
The example below is fully functional and expects a Puppet server to be
accessible from your network.
2014-01-08 06:46:34 -05:00
2017-06-14 21:04:16 -04:00
``` json
2014-01-08 06:46:34 -05:00
{
"type": "puppet-server",
"extra_arguments": "--test --pluginsync",
2014-01-08 06:46:34 -05:00
"facter": {
"server_role": "webserver"
}
}
```
2014-01-08 06:46:34 -05:00
## Configuration Reference
The reference of available configuration options is listed below.
2015-07-22 22:31:00 -04:00
The provisioner takes various options. None are strictly required. They are
listed below:
2014-01-08 06:46:34 -05:00
2017-06-14 21:04:16 -04:00
- `client_cert_path` (string) - Path to the directory on your disk that
2018-10-26 20:02:51 -04:00
contains the client certificate for the node. This defaults to nothing, in
which case a client cert won't be uploaded.
- `client_private_key_path` (string) - Path to the directory on your disk
that contains the client private key for the node. This defaults to
nothing, in which case a client private key won't be uploaded.
- `execute_command` (string) - The command-line to execute Puppet. This also
has various [configuration template variables](/docs/templates/engine.html)
available.
- `extra_arguments` (array of strings) - Additional options to pass to the
Puppet command. This allows for customization of `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-server/provisioner.go).
[
{{if ne "{{user environment}}" ""}}--environment={{user environment}}{{end}}
]
2018-05-08 09:53:18 -04:00
- `facter` (object of key/value strings) - Additional
2018-10-26 20:02:51 -04:00
[facts](https://puppetlabs.com/facter) to make available to the Puppet run.
2014-01-08 06:46:34 -05: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).
- `ignore_exit_codes` (boolean) - If true, Packer will ignore failures.
2015-06-19 00:09:22 -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)
2014-01-08 06:46:34 -05: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
might be empty or minimal.
2017-06-14 21:04:16 -04:00
- `puppet_node` (string) - The name of the node. If this isn't set, the fully
2015-07-22 23:25:58 -04:00
qualified domain name will be used.
2014-01-08 06:46:34 -05:00
2017-06-14 21:04:16 -04:00
- `puppet_server` (string) - Hostname of the Puppet server. By default
2015-07-22 23:25:58 -04:00
"puppet" will be used.
2014-01-08 06:46:34 -05:00
2018-10-26 20:02:51 -04:00
- `staging_dir` (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-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`)
## Execute Command
By default, Packer uses the following command (broken across multiple lines for
readability) to execute Puppet:
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 agent --onetime --no-daemonize --detailed-exitcodes
{{if .Debug}}--debug {{end}}
{{if ne .PuppetServer ""}}--server='{{.PuppetServer}}' {{end}}
{{if ne .PuppetNode ""}}--certname='{{.PuppetNode}}' {{end}}
{{if ne .ClientCertPath ""}}--certdir='{{.ClientCertPath}}' {{end}}
{{if ne .ClientPrivateKeyPath ""}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}}
{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}
The following command is used if guest OS type is windows:
2018-10-26 20:02:51 -04:00
cd {{.WorkingDir}} &&
{{if ne .FacterVars ""}}{{.FacterVars}} && {{end}}
{{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}}
puppet agent --onetime --no-daemonize --detailed-exitcodes
{{if .Debug}}--debug {{end}}
{{if ne .PuppetServer ""}}--server='{{.PuppetServer}}' {{end}}
{{if ne .PuppetNode ""}}--certname='{{.PuppetNode}}' {{end}}
{{if ne .ClientCertPath ""}}--certdir='{{.ClientCertPath}}' {{end}}
{{if ne .ClientPrivateKeyPath ""}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}}
{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}
## 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.
This is most useful when Packer is making multiple builds and you want to
distinguish them in your Hiera hierarchy.
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.