alphabetize datastructures
This commit is contained in:
parent
f5f69df84e
commit
514a597825
|
@ -20,21 +20,27 @@ type Config struct {
|
|||
common.PackerConfig `mapstructure:",squash"`
|
||||
ctx interpolate.Context
|
||||
|
||||
// If true, staging directory is removed after executing puppet.
|
||||
CleanStagingDir bool `mapstructure:"clean_staging_directory"`
|
||||
|
||||
// The Guest OS Type (unix or windows)
|
||||
GuestOSType string `mapstructure:"guest_os_type"`
|
||||
|
||||
// The command used to execute Puppet.
|
||||
ExecuteCommand string `mapstructure:"execute_command"`
|
||||
|
||||
// Additional arguments to pass when executing Puppet
|
||||
ExtraArguments []string `mapstructure:"extra_arguments"`
|
||||
|
||||
// The Guest OS Type (unix or windows)
|
||||
GuestOSType string `mapstructure:"guest_os_type"`
|
||||
|
||||
// Additional facts to set when executing Puppet
|
||||
Facter map[string]string
|
||||
|
||||
// Path to a hiera configuration file to upload and use.
|
||||
HieraConfigPath string `mapstructure:"hiera_config_path"`
|
||||
|
||||
// If true, packer will ignore all exit-codes from a puppet run
|
||||
IgnoreExitCodes bool `mapstructure:"ignore_exit_codes"`
|
||||
|
||||
// An array of local paths of modules to upload.
|
||||
ModulePaths []string `mapstructure:"module_paths"`
|
||||
|
||||
|
@ -48,32 +54,26 @@ type Config struct {
|
|||
// If true, `sudo` will NOT be used to execute Puppet.
|
||||
PreventSudo bool `mapstructure:"prevent_sudo"`
|
||||
|
||||
// The directory that contains the puppet binary.
|
||||
// E.g. if it can't be found on the standard path.
|
||||
PuppetBinDir string `mapstructure:"puppet_bin_dir"`
|
||||
|
||||
// The directory where files will be uploaded. Packer requires write
|
||||
// permissions in this directory.
|
||||
StagingDir string `mapstructure:"staging_directory"`
|
||||
|
||||
// If true, staging directory is removed after executing puppet.
|
||||
CleanStagingDir bool `mapstructure:"clean_staging_directory"`
|
||||
|
||||
// The directory from which the command will be executed.
|
||||
// Packer requires the directory to exist when running puppet.
|
||||
WorkingDir string `mapstructure:"working_directory"`
|
||||
|
||||
// The directory that contains the puppet binary.
|
||||
// E.g. if it can't be found on the standard path.
|
||||
PuppetBinDir string `mapstructure:"puppet_bin_dir"`
|
||||
|
||||
// If true, packer will ignore all exit-codes from a puppet run
|
||||
IgnoreExitCodes bool `mapstructure:"ignore_exit_codes"`
|
||||
}
|
||||
|
||||
type guestOSTypeConfig struct {
|
||||
tempDir string
|
||||
stagingDir string
|
||||
executeCommand string
|
||||
facterVarsFmt string
|
||||
facterVarsJoiner string
|
||||
modulePathJoiner string
|
||||
stagingDir string
|
||||
tempDir string
|
||||
}
|
||||
|
||||
// FIXME assumes both Packer host and target are same OS
|
||||
|
@ -122,6 +122,8 @@ type Provisioner struct {
|
|||
}
|
||||
|
||||
type ExecuteTemplate struct {
|
||||
Debug bool
|
||||
ExtraArguments string
|
||||
FacterVars string
|
||||
HieraConfigPath string
|
||||
ModulePath string
|
||||
|
@ -130,8 +132,6 @@ type ExecuteTemplate struct {
|
|||
PuppetBinDir string
|
||||
Sudo bool
|
||||
WorkingDir string
|
||||
Debug bool
|
||||
ExtraArguments string
|
||||
}
|
||||
|
||||
func (p *Provisioner) Prepare(raws ...interface{}) error {
|
||||
|
@ -291,6 +291,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
|||
}
|
||||
|
||||
data := ExecuteTemplate{
|
||||
ExtraArguments: "",
|
||||
FacterVars: strings.Join(facterVars, p.guestOSTypeConfig.facterVarsJoiner),
|
||||
HieraConfigPath: remoteHieraConfigPath,
|
||||
ManifestDir: remoteManifestDir,
|
||||
|
@ -299,7 +300,6 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
|||
PuppetBinDir: p.config.PuppetBinDir,
|
||||
Sudo: !p.config.PreventSudo,
|
||||
WorkingDir: p.config.WorkingDir,
|
||||
ExtraArguments: "",
|
||||
}
|
||||
|
||||
p.config.ctx.Data = &data
|
||||
|
|
|
@ -19,17 +19,8 @@ type Config struct {
|
|||
common.PackerConfig `mapstructure:",squash"`
|
||||
ctx interpolate.Context
|
||||
|
||||
// The command used to execute Puppet.
|
||||
ExecuteCommand string `mapstructure:"execute_command"`
|
||||
|
||||
// Additional argument to pass when executing Puppet.
|
||||
ExtraArguments []string `mapstructure:"extra_arguments"`
|
||||
|
||||
// The Guest OS Type (unix or windows)
|
||||
GuestOSType string `mapstructure:"guest_os_type"`
|
||||
|
||||
// Additional facts to set when executing Puppet
|
||||
Facter map[string]string
|
||||
// If true, staging directory is removed after executing puppet.
|
||||
CleanStagingDir bool `mapstructure:"clean_staging_directory"`
|
||||
|
||||
// A path to the client certificate
|
||||
ClientCertPath string `mapstructure:"client_cert_path"`
|
||||
|
@ -37,15 +28,34 @@ type Config struct {
|
|||
// A path to a directory containing the client private keys
|
||||
ClientPrivateKeyPath string `mapstructure:"client_private_key_path"`
|
||||
|
||||
// The command used to execute Puppet.
|
||||
ExecuteCommand string `mapstructure:"execute_command"`
|
||||
|
||||
// Additional argument to pass when executing Puppet.
|
||||
ExtraArguments []string `mapstructure:"extra_arguments"`
|
||||
|
||||
// Additional facts to set when executing Puppet
|
||||
Facter map[string]string
|
||||
|
||||
// The Guest OS Type (unix or windows)
|
||||
GuestOSType string `mapstructure:"guest_os_type"`
|
||||
|
||||
// If true, packer will ignore all exit-codes from a puppet run
|
||||
IgnoreExitCodes bool `mapstructure:"ignore_exit_codes"`
|
||||
|
||||
// If true, `sudo` will NOT be used to execute Puppet.
|
||||
PreventSudo bool `mapstructure:"prevent_sudo"`
|
||||
|
||||
// The directory that contains the puppet binary.
|
||||
// E.g. if it can't be found on the standard path.
|
||||
PuppetBinDir string `mapstructure:"puppet_bin_dir"`
|
||||
|
||||
// The hostname of the Puppet node.
|
||||
PuppetNode string `mapstructure:"puppet_node"`
|
||||
|
||||
// The hostname of the Puppet server.
|
||||
PuppetServer string `mapstructure:"puppet_server"`
|
||||
|
||||
// If true, `sudo` will NOT be used to execute Puppet.
|
||||
PreventSudo bool `mapstructure:"prevent_sudo"`
|
||||
|
||||
// The directory where files will be uploaded. Packer requires write
|
||||
// permissions in this directory.
|
||||
StagingDir string `mapstructure:"staging_dir"`
|
||||
|
@ -53,21 +63,14 @@ type Config struct {
|
|||
// The directory from which the command will be executed.
|
||||
// Packer requires the directory to exist when running puppet.
|
||||
WorkingDir string `mapstructure:"working_directory"`
|
||||
|
||||
// The directory that contains the puppet binary.
|
||||
// E.g. if it can't be found on the standard path.
|
||||
PuppetBinDir string `mapstructure:"puppet_bin_dir"`
|
||||
|
||||
// If true, packer will ignore all exit-codes from a puppet run
|
||||
IgnoreExitCodes bool `mapstructure:"ignore_exit_codes"`
|
||||
}
|
||||
|
||||
type guestOSTypeConfig struct {
|
||||
tempDir string
|
||||
stagingDir string
|
||||
executeCommand string
|
||||
facterVarsFmt string
|
||||
facterVarsJoiner string
|
||||
stagingDir string
|
||||
tempDir string
|
||||
}
|
||||
|
||||
// FIXME assumes both Packer host and target are same OS
|
||||
|
@ -114,16 +117,16 @@ type Provisioner struct {
|
|||
}
|
||||
|
||||
type ExecuteTemplate struct {
|
||||
FacterVars string
|
||||
ClientCertPath string
|
||||
ClientPrivateKeyPath string
|
||||
Debug bool
|
||||
ExtraArguments string
|
||||
FacterVars string
|
||||
PuppetNode string
|
||||
PuppetServer string
|
||||
PuppetBinDir string
|
||||
Sudo bool
|
||||
WorkingDir string
|
||||
Debug bool
|
||||
ExtraArguments string
|
||||
}
|
||||
|
||||
func (p *Provisioner) Prepare(raws ...interface{}) error {
|
||||
|
@ -243,15 +246,15 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
|||
}
|
||||
|
||||
data := ExecuteTemplate{
|
||||
FacterVars: strings.Join(facterVars, p.guestOSTypeConfig.facterVarsJoiner),
|
||||
ClientCertPath: remoteClientCertPath,
|
||||
ClientPrivateKeyPath: remoteClientPrivateKeyPath,
|
||||
ExtraArguments: "",
|
||||
FacterVars: strings.Join(facterVars, p.guestOSTypeConfig.facterVarsJoiner),
|
||||
PuppetNode: p.config.PuppetNode,
|
||||
PuppetServer: p.config.PuppetServer,
|
||||
PuppetBinDir: p.config.PuppetBinDir,
|
||||
Sudo: !p.config.PreventSudo,
|
||||
WorkingDir: p.config.WorkingDir,
|
||||
ExtraArguments: "",
|
||||
}
|
||||
|
||||
p.config.ctx.Data = &data
|
||||
|
@ -279,6 +282,12 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
|||
return fmt.Errorf("Puppet exited with a non-zero exit status: %d", cmd.ExitStatus)
|
||||
}
|
||||
|
||||
if p.config.CleanStagingDir {
|
||||
if err := p.removeDir(ui, comm, p.config.StagingDir); err != nil {
|
||||
return fmt.Errorf("Error removing staging directory: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue