From b505cecd985839ca355e60423f163250bc28ac3d Mon Sep 17 00:00:00 2001 From: Matthew Patton Date: Tue, 8 May 2018 09:53:18 -0400 Subject: [PATCH] sync docs to code --- provisioner/puppet-masterless/provisioner.go | 4 +- provisioner/puppet-server/provisioner.go | 8 +-- .../provisioners/puppet-masterless.html.md | 70 +++++++++---------- .../docs/provisioners/puppet-server.html.md | 53 +++++++++----- 4 files changed, 74 insertions(+), 61 deletions(-) diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index 882d4fa9d..c0819b89b 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -90,7 +90,7 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{ `{{if ne .ModulePath ""}}--modulepath='{{.ModulePath}}' {{end}}` + `{{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}}` + `{{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}}` + - `{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}` + + "{{.ExtraArguments}} " + "{{.ManifestFile}}", facterVarsFmt: "FACTER_%s='%s'", facterVarsJoiner: " ", @@ -107,7 +107,7 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{ `{{if ne .ModulePath ""}}--modulepath='{{.ModulePath}}' {{end}}` + `{{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}}` + `{{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}}` + - `{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}` + + "{{.ExtraArguments}} " + "{{.ManifestFile}}", facterVarsFmt: `SET "FACTER_%s=%s"`, facterVarsJoiner: " & ", diff --git a/provisioner/puppet-server/provisioner.go b/provisioner/puppet-server/provisioner.go index 9535684f0..2118bd60e 100644 --- a/provisioner/puppet-server/provisioner.go +++ b/provisioner/puppet-server/provisioner.go @@ -85,10 +85,10 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{ "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 .PuppetNode ""}}--certname='{{.PuppetNode}}' {{end}}` + `{{if ne .ClientCertPath ""}}--certdir='{{.ClientCertPath}}' {{end}}` + `{{if ne .ClientPrivateKeyPath ""}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}}` + - `{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}`, + "{{.ExtraArguments}} ", facterVarsFmt: "FACTER_%s='%s'", facterVarsJoiner: " ", }, @@ -101,10 +101,10 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{ "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 .PuppetNode ""}}--certname='{{.PuppetNode}}' {{end}}` + `{{if ne .ClientCertPath ""}}--certdir='{{.ClientCertPath}}' {{end}}` + `{{if ne .ClientPrivateKeyPath ""}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}}` + - `{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}`, + "{{.ExtraArguments}} ", facterVarsFmt: `SET "FACTER_%s=%s"`, facterVarsJoiner: " & ", }, diff --git a/website/source/docs/provisioners/puppet-masterless.html.md b/website/source/docs/provisioners/puppet-masterless.html.md index 1e1689d03..448a2e880 100644 --- a/website/source/docs/provisioners/puppet-masterless.html.md +++ b/website/source/docs/provisioners/puppet-masterless.html.md @@ -59,11 +59,19 @@ Optional parameters: variables](/docs/templates/engine.html) available. See below for more information. -- `extra_arguments` (array of strings) - This is an array of additional options to - 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. +- `extra_arguments` (array of strings) - Additional options to + pass to the Puppet command. This allows for customization of the + `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 other parameters. +``` +[ + {{if ne "{{user environment}}" ""}}--environment={{user environment}}{{end}}, + {{if ne ".ModulePath" ""}}--modulepath='{{.ModulePath}}:$({{.PuppetBinDir}}/puppet config print {{if ne "{{user `environment`}}" ""}}--environment={{user `environment`}}{{end}} modulepath)'{{end}} +] +``` - `facter` (object of key/value strings) - Additional [facts](https://puppetlabs.com/facter) to make @@ -71,7 +79,7 @@ Optional parameters: - `guest_os_type` (string) - The target guest OS type, either "unix" or "windows". Setting this to "windows" will cause the provisioner to use - Windows friendly paths and commands. By default, this is "unix". + Windows friendly paths and commands. By default, this is "unix". - `hiera_config_path` (string) - The path to a local file with hiera configuration to be uploaded to the remote machine. Hiera data directories @@ -124,45 +132,33 @@ readability) to execute Puppet: ``` cd {{.WorkingDir}} && - {{if ne .FacterVars ""}}{{.FacterVars}} {{end}} -{{if .Sudo}}sudo -E {{end}} -{{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}} -puppet apply --verbose --modulepath='{{.ModulePath}}' - {{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}} -{{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}} ---detailed-exitcodes - {{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}} -{{.ManifestFile}} + {{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}} + {{.ExtraArguments}} + {{.ManifestFile}} ``` The following command is used if guest OS type is windows: ``` cd {{.WorkingDir}} && - {{.FacterVars}} && - {{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}} -puppet apply --verbose --modulepath='{{.ModulePath}}' - {{if ne .HieraConfigPath ""}}--hiera_config='{{.HieraConfigPath}}' {{end}} -{{if ne .ManifestDir ""}}--manifestdir='{{.ManifestDir}}' {{end}} ---detailed-exitcodes - {{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}} -{{.ManifestFile}} + {{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}} + {{.ExtraArguments}} + {{.ManifestFile}} ``` -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: - -- `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. - ## Default Facts In addition to being able to specify custom Facter facts using the `facter` diff --git a/website/source/docs/provisioners/puppet-server.html.md b/website/source/docs/provisioners/puppet-server.html.md index 180f52b02..af09b9ace 100644 --- a/website/source/docs/provisioners/puppet-server.html.md +++ b/website/source/docs/provisioners/puppet-server.html.md @@ -54,6 +54,20 @@ listed below: various [configuration template variables](/docs/templates/engine.html) available. See below for more information. +- `extra_arguments` (array of strings) - Additional options to + pass to the puppet command. This allows for customization of the + `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 other parameters. +``` +[ + {{if ne "{{user environment}}" ""}}--environment={{user environment}}{{end}} + {{if ne ".ModulePath" ""}}--modulepath='{{.ModulePath}}:$({{.PuppetBinDir}}/puppet config print {{if ne "{{user `environment`}}" ""}}--environment={{user `environment`}}{{end}} modulepath)'{{end}} +] +``` + - `facter` (object of key/value strings) - Additional Facter facts to make available to the Puppet run. @@ -95,29 +109,32 @@ By default, Packer uses the following command (broken across multiple lines for readability) to execute Puppet: ``` -{{.FacterVars}} {{if .Sudo}}sudo -E {{end}} -{{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}}puppet agent ---onetime --no-daemonize -{{if ne .PuppetServer ""}}--server='{{.PuppetServer}}' {{end}} -{{if ne .Options ""}}{{.Options}} {{end}} -{{if ne .PuppetNode ""}}--certname={{.PuppetNode}} {{end}} -{{if ne .ClientCertPath ""}}--certdir='{{.ClientCertPath}}' {{end}} -{{if ne .ClientPrivateKeyPath ""}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}} ---detailed-exitcodes +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}} + "{{.ExtraArguments}} " ``` The following command is used if guest OS type is windows: ``` -{{.FacterVars}} -{{if ne .PuppetBinDir ""}}{{.PuppetBinDir}}/{{end}}puppet agent ---onetime --no-daemonize -{{if ne .PuppetServer ""}}--server='{{.PuppetServer}}' {{end}} -{{if ne .Options ""}}{{.Options}} {{end}} -{{if ne .PuppetNode ""}}--certname={{.PuppetNode}} {{end}} -{{if ne .ClientCertPath ""}}--certdir='{{.ClientCertPath}}' {{end}} -{{if ne .ClientPrivateKeyPath ""}}--privatekeydir='{{.ClientPrivateKeyPath}}' {{end}} ---detailed-exitcodes +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}} + "{{.ExtraArguments}} " ``` ## Default Facts