github.com/aclaygray/packer@v1.3.2/website/source/docs/provisioners/puppet-server.html.md (about) 1 --- 2 description: | 3 The puppet-server Packer provisioner provisions Packer machines with Puppet 4 by connecting to a Puppet master. 5 layout: docs 6 page_title: 'Puppet Server - Provisioners' 7 sidebar_current: 'docs-provisioners-puppet-server' 8 --- 9 10 # Puppet Server Provisioner 11 12 Type: `puppet-server` 13 14 The `puppet-server` Packer provisioner provisions Packer machines with Puppet by 15 connecting to a Puppet master. 16 17 -> **Note:** Puppet will *not* be installed automatically by this 18 provisioner. This provisioner expects that Puppet is already installed on the 19 machine. It is common practice to use the [shell 20 provisioner](/docs/provisioners/shell.html) before the Puppet provisioner to do 21 this. 22 23 ## Basic Example 24 25 The example below is fully functional and expects a Puppet server to be 26 accessible from your network. 27 28 ``` json 29 { 30 "type": "puppet-server", 31 "extra_arguments": "--test --pluginsync", 32 "facter": { 33 "server_role": "webserver" 34 } 35 } 36 ``` 37 38 ## Configuration Reference 39 40 The reference of available configuration options is listed below. 41 42 The provisioner takes various options. None are strictly required. They are 43 listed below: 44 45 - `client_cert_path` (string) - Path to the directory on your disk that 46 contains the client certificate for the node. This defaults to nothing, 47 in which case a client cert won't be uploaded. 48 49 - `client_private_key_path` (string) - Path to the directory on your disk that 50 contains the client private key for the node. This defaults to nothing, in 51 which case a client private key won't be uploaded. 52 53 - `execute_command` (string) - The command-line to execute Puppet. This also has 54 various [configuration template variables](/docs/templates/engine.html) available. 55 56 - `extra_arguments` (array of strings) - Additional options to 57 pass to the Puppet command. This allows for customization of 58 `execute_command` without having to completely replace 59 or subsume its contents, making forward-compatible customizations much 60 easier to maintain. 61 62 This string is lazy-evaluated so one can incorporate logic driven by template variables as 63 well as private elements of ExecuteTemplate (see source: provisioner/puppet-server/provisioner.go). 64 ``` 65 [ 66 {{if ne "{{user environment}}" ""}}--environment={{user environment}}{{end}} 67 ] 68 ``` 69 70 - `facter` (object of key/value strings) - Additional 71 [facts](https://puppetlabs.com/facter) to make 72 available to the Puppet run. 73 74 - `guest_os_type` (string) - The remote host's OS type ('windows' or 'unix') to 75 tailor command-line and path separators. (default: unix). 76 77 - `ignore_exit_codes` (boolean) - If true, Packer will ignore failures. 78 79 - `prevent_sudo` (boolean) - On Unix platforms Puppet is typically invoked with `sudo`. If true, 80 it will be omitted. (default: false) 81 82 - `puppet_bin_dir` (string) - Path to the Puppet binary. Ideally the program 83 should be on the system (unix: `$PATH`, windows: `%PATH%`), but some builders (eg. Docker) do 84 not run profile-setup scripts and therefore PATH might be empty or minimal. 85 86 - `puppet_node` (string) - The name of the node. If this isn't set, the fully 87 qualified domain name will be used. 88 89 - `puppet_server` (string) - Hostname of the Puppet server. By default 90 "puppet" will be used. 91 92 - `staging_dir` (string) - Directory to where uploaded files 93 will be placed (unix: "/tmp/packer-puppet-masterless", 94 windows: "%SYSTEMROOT%/Temp/packer-puppet-masterless"). 95 It doesn't need to pre-exist, but the parent must have permissions sufficient 96 for the account Packer connects as to create directories and write files. 97 Use a Shell provisioner to prepare the way if needed. 98 99 - `working_directory` (string) - Directory from which `execute_command` will be run. 100 If using Hiera files with relative paths, this option can be helpful. (default: `staging_directory`) 101 102 ## Execute Command 103 104 By default, Packer uses the following command (broken across multiple lines for 105 readability) to execute Puppet: 106 107 ``` 108 cd {{.WorkingDir}} && 109 {{if ne .FacterVars ""}}{{.FacterVars}} {{end}} 110 {{if .Sudo}}sudo -E {{end}} 111 {{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}} 112 puppet agent --onetime --no-daemonize --detailed-exitcodes 113 {{if .Debug}}--debug {{end}} 114 {{if ne .PuppetServer ""}}--server='{{.PuppetServer}}' {{end}} 115 {{if ne .PuppetNode ""}}--certname='{{.PuppetNode}}' {{end}} 116 {{if ne .ClientCertPath ""}}--certdir='{{.ClientCertPath}}' {{end}} 117 {{if ne .ClientPrivateKeyPath ""}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}} 118 {{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}} 119 ``` 120 121 The following command is used if guest OS type is windows: 122 123 ``` 124 cd {{.WorkingDir}} && 125 {{if ne .FacterVars ""}}{{.FacterVars}} && {{end}} 126 {{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}} 127 puppet agent --onetime --no-daemonize --detailed-exitcodes 128 {{if .Debug}}--debug {{end}} 129 {{if ne .PuppetServer ""}}--server='{{.PuppetServer}}' {{end}} 130 {{if ne .PuppetNode ""}}--certname='{{.PuppetNode}}' {{end}} 131 {{if ne .ClientCertPath ""}}--certdir='{{.ClientCertPath}}' {{end}} 132 {{if ne .ClientPrivateKeyPath ""}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}} 133 {{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}} 134 ``` 135 136 ## Default Facts 137 138 In addition to being able to specify custom Facter facts using the `facter` 139 configuration, the provisioner automatically defines certain commonly useful 140 facts: 141 142 - `packer_build_name` is set to the name of the build that Packer is running. 143 This is most useful when Packer is making multiple builds and you want to 144 distinguish them in your Hiera hierarchy. 145 146 - `packer_builder_type` is the type of the builder that was used to create the 147 machine that Puppet is running on. This is useful if you want to run only 148 certain parts of your Puppet code on systems built with certain builders.