From 80ba99c04f26c8220c53c4430138c9e58934dc41 Mon Sep 17 00:00:00 2001 From: c22 Date: Fri, 13 Jan 2017 19:11:18 +1100 Subject: [PATCH] Update documentation + small fixes Updated the puppet-masterless documentation Removed extraneous ConfigTemplate code --- provisioner/puppet-masterless/provisioner.go | 19 ++----- .../provisioners/puppet-masterless.html.md | 50 ++++++++++++------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index bdc41e435..e64e5f7dd 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -63,8 +63,8 @@ type Config struct { // If true, packer will ignore all exit-codes from a puppet run IgnoreExitCodes bool `mapstructure:"ignore_exit_codes"` - GuestOSType string `mapstructure:"guest_os_type"` - ConfigTemplate string `mapstructure:"config_template"` + // The Guest OS Type (unix or windows) + GuestOSType string `mapstructure:"guest_os_type"` } type guestOSTypeConfig struct { @@ -73,7 +73,7 @@ type guestOSTypeConfig struct { } var guestOSTypeConfigs = map[string]guestOSTypeConfig{ - provisioner.UnixOSType: guestOSTypeConfig{ + provisioner.UnixOSType: { stagingDir: "/tmp/packer-puppet-masterless", executeCommand: "cd {{.WorkingDir}} && " + "{{.FacterVars}} {{if .Sudo}} sudo -E {{end}}" + @@ -84,7 +84,7 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{ "{{if ne .ExtraArguments \"\"}}{{.ExtraArguments}} {{end}}" + "{{.ManifestFile}}", }, - provisioner.WindowsOSType: guestOSTypeConfig{ + provisioner.WindowsOSType: { stagingDir: "C:/Windows/Temp/packer-puppet-masterless", executeCommand: "cd {{.WorkingDir}} && " + "{{.FacterVars}} && " + @@ -214,17 +214,6 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.ExecuteCommand = p.guestOSTypeConfig.executeCommand } - if p.config.ConfigTemplate != "" { - fi, err := os.Stat(p.config.ConfigTemplate) - if err != nil { - errs = packer.MultiErrorAppend( - errs, fmt.Errorf("Bad config template path: %s", err)) - } else if fi.IsDir() { - errs = packer.MultiErrorAppend( - errs, fmt.Errorf("Config template path must be a file: %s", err)) - } - } - if errs != nil && len(errs.Errors) > 0 { return errs } diff --git a/website/source/docs/provisioners/puppet-masterless.html.md b/website/source/docs/provisioners/puppet-masterless.html.md index c630f8412..4d697ecce 100644 --- a/website/source/docs/provisioners/puppet-masterless.html.md +++ b/website/source/docs/provisioners/puppet-masterless.html.md @@ -59,6 +59,10 @@ Optional parameters: variables](/docs/templates/engine.html) available. See below for more information. +- `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". + - `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 @@ -99,12 +103,13 @@ multiple manifests you should use `manifest_file` instead. executed to run Puppet are executed with `sudo`. If this is true, then the sudo will be omitted. -- `staging_directory` (string) - This is the directory where all the - configuration of Puppet by Packer will be placed. By default this - is "/tmp/packer-puppet-masterless". This directory doesn't need to exist but - must have proper permissions so that the SSH user that Packer uses is able - to create directories and write into this folder. If the permissions are not - correct, use a shell provisioner prior to this to configure it properly. +- `staging_directory` (string) - This is the directory where all the configuration + of Puppet by Packer will be placed. By default this is "/tmp/packer-puppet-masterless" + when guest_os_type unix and "C:/Windows/Temp/packer-puppet-masterless" when windows. + This directory doesn't need to exist but must have proper permissions so that the SSH + user that Packer uses is able to create directories and write into this folder. + If the permissions are not correct, use a shell provisioner prior to this to configure + it properly. - `working_directory` (string) - This is the directory from which the puppet command will be run. When using hiera with a relative path, this option @@ -117,17 +122,28 @@ multiple manifests you should use `manifest_file` instead. By default, Packer uses the following command (broken across multiple lines for readability) to execute Puppet: -``` liquid -cd {{.WorkingDir}} && \ -{{.FacterVars}}{{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}} +``` +cd {{.WorkingDir}} && +{{.FacterVars}} {{if .Sudo}} sudo -E {{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}} +``` + +The following command is used if guest_os_type is windows: + +``` +cd {{.WorkingDir}} && +{{.FacterVars}} && +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}} ``` This command can be customized using the `execute_command` configuration. As you