github.com/mmcquillan/packer@v1.1.1-0.20171009221028-c85cf0483a5d/website/source/docs/provisioners/puppet-masterless.html.md (about) 1 --- 2 description: | 3 The masterless Puppet Packer provisioner configures Puppet to run on the 4 machines by Packer from local modules and manifest files. Modules and 5 manifests can be uploaded from your local machine to the remote machine or can 6 simply use remote paths. Puppet is run in masterless mode, meaning it never 7 communicates to a Puppet master. 8 layout: docs 9 page_title: 'Puppet Masterless - Provisioners' 10 sidebar_current: 'docs-provisioners-puppet-masterless' 11 --- 12 13 # Puppet (Masterless) Provisioner 14 15 Type: `puppet-masterless` 16 17 The masterless Puppet Packer provisioner configures Puppet to run on the 18 machines by Packer from local modules and manifest files. Modules and manifests 19 can be uploaded from your local machine to the remote machine or can simply use 20 remote paths (perhaps obtained using something like the shell provisioner). 21 Puppet is run in masterless mode, meaning it never communicates to a Puppet 22 master. 23 24 -> **Note:** Puppet will *not* be installed automatically by this 25 provisioner. This provisioner expects that Puppet is already installed on the 26 machine. It is common practice to use the [shell 27 provisioner](/docs/provisioners/shell.html) before the Puppet provisioner to do 28 this. 29 30 ## Basic Example 31 32 The example below is fully functional and expects the configured manifest file 33 to exist relative to your working directory. 34 35 ``` json 36 { 37 "type": "puppet-masterless", 38 "manifest_file": "site.pp" 39 } 40 ``` 41 42 ## Configuration Reference 43 44 The reference of available configuration options is listed below. 45 46 Required parameters: 47 48 - `manifest_file` (string) - This is either a path to a puppet manifest 49 (`.pp` file) *or* a directory containing multiple manifests that puppet will 50 apply (the ["main 51 manifest"](https://docs.puppetlabs.com/puppet/latest/reference/dirs_manifest.html)). 52 These file(s) must exist on your local system and will be uploaded to the 53 remote machine. 54 55 Optional parameters: 56 57 - `execute_command` (string) - The command used to execute Puppet. This has 58 various [configuration template 59 variables](/docs/templates/engine.html) available. See 60 below for more information. 61 62 - `guest_os_type` (string) - The target guest OS type, either "unix" or 63 "windows". Setting this to "windows" will cause the provisioner to use 64 Windows friendly paths and commands. By default, this is "unix". 65 66 - `extra_arguments` (array of strings) - This is an array of additional options to 67 pass to the puppet command when executing puppet. This allows for 68 customization of the `execute_command` without having to completely replace 69 or include it's contents, making forward-compatible customizations much 70 easier. 71 72 - `facter` (object of key/value strings) - Additional 73 [facts](https://puppetlabs.com/facter) to make 74 available when Puppet is running. 75 76 - `hiera_config_path` (string) - The path to a local file with hiera 77 configuration to be uploaded to the remote machine. Hiera data directories 78 must be uploaded using the file provisioner separately. 79 80 - `ignore_exit_codes` (boolean) - If true, Packer will never consider the 81 provisioner a failure. 82 83 - `manifest_dir` (string) - The path to a local directory with manifests to be 84 uploaded to the remote machine. This is useful if your main manifest file 85 uses imports. This directory doesn't necessarily contain the 86 `manifest_file`. It is a separate directory that will be set as the 87 "manifestdir" setting on Puppet. 88 89 ~> `manifest_dir` is passed to `puppet apply` as the `--manifestdir` option. 90 This option was deprecated in puppet 3.6, and removed in puppet 4.0. If you have 91 multiple manifests you should use `manifest_file` instead. 92 93 - `puppet_bin_dir` (string) - The path to the directory that contains the puppet 94 binary for running `puppet apply`. Usually, this would be found via the `$PATH` 95 or `%PATH%` environment variable, but some builders (notably, the Docker one) do 96 not run profile-setup scripts, therefore the path is usually empty. 97 98 - `module_paths` (array of strings) - This is an array of paths to module 99 directories on your local filesystem. These will be uploaded to the 100 remote machine. By default, this is empty. 101 102 - `prevent_sudo` (boolean) - By default, the configured commands that are 103 executed to run Puppet are executed with `sudo`. If this is true, then the 104 sudo will be omitted. 105 106 - `staging_directory` (string) - This is the directory where all the configuration 107 of Puppet by Packer will be placed. By default this is "/tmp/packer-puppet-masterless" 108 when guest OS type is unix and "C:/Windows/Temp/packer-puppet-masterless" when windows. 109 This directory doesn't need to exist but must have proper permissions so that the SSH 110 user that Packer uses is able to create directories and write into this folder. 111 If the permissions are not correct, use a shell provisioner prior to this to configure 112 it properly. 113 114 - `working_directory` (string) - This is the directory from which the puppet 115 command will be run. When using hiera with a relative path, this option 116 allows to ensure that the paths are working properly. If not specified, 117 defaults to the value of specified `staging_directory` (or its default value 118 if not specified either). 119 120 ## Execute Command 121 122 By default, Packer uses the following command (broken across multiple lines for 123 readability) to execute Puppet: 124 125 ``` 126 cd {{.WorkingDir}} && 127 {{if ne .FacterVars ""}}{{.FacterVars}} {{end}} 128 {{if .Sudo}}sudo -E {{end}} 129 {{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}} 130 puppet apply --verbose --modulepath='{{.ModulePath}}' 131 {{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}} 132 {{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}} 133 --detailed-exitcodes 134 {{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}} 135 {{.ManifestFile}} 136 ``` 137 138 The following command is used if guest OS type is windows: 139 140 ``` 141 cd {{.WorkingDir}} && 142 {{.FacterVars}} && 143 {{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}} 144 puppet apply --verbose --modulepath='{{.ModulePath}}' 145 {{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}} 146 {{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}} 147 --detailed-exitcodes 148 {{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}} 149 {{.ManifestFile}} 150 ``` 151 152 This command can be customized using the `execute_command` configuration. As you 153 can see from the default value above, the value of this configuration can 154 contain various template variables, defined below: 155 156 - `WorkingDir` - The path from which Puppet will be executed. 157 - `FacterVars` - Shell-friendly string of environmental variables used to set 158 custom facts configured for this provisioner. 159 - `HieraConfigPath` - The path to a hiera configuration file. 160 - `ManifestFile` - The path on the remote machine to the manifest file for 161 Puppet to use. 162 - `ModulePath` - The paths to the module directories. 163 - `Sudo` - A boolean of whether to `sudo` the command or not, depending on the 164 value of the `prevent_sudo` configuration. 165 166 ## Default Facts 167 168 In addition to being able to specify custom Facter facts using the `facter` 169 configuration, the provisioner automatically defines certain commonly useful 170 facts: 171 172 - `packer_build_name` is set to the name of the build that Packer is running. 173 This is most useful when Packer is making multiple builds and you want to 174 distinguish them in your Hiera hierarchy. 175 176 - `packer_builder_type` is the type of the builder that was used to create the 177 machine that Puppet is running on. This is useful if you want to run only 178 certain parts of your Puppet code on systems built with certain builders.