provisioner/puppet-masterless: simplify manifest dir upload
This commit is contained in:
parent
6aef114372
commit
2986452804
|
@ -31,7 +31,8 @@ type Config struct {
|
|||
// The main manifest file to apply to kick off the entire thing.
|
||||
ManifestFile string `mapstructure:"manifest_file"`
|
||||
|
||||
// The manifest dir, e.g. for includes
|
||||
// A directory of manifest files that will be uploaded to the remote
|
||||
// machine.
|
||||
ManifestDir string `mapstructure:"manifest_dir"`
|
||||
|
||||
// If true, `sudo` will NOT be used to execute Puppet.
|
||||
|
@ -214,8 +215,10 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
|||
// Upload manifest dir if set
|
||||
remoteManifestDir := ""
|
||||
if p.config.ManifestDir != "" {
|
||||
var err error
|
||||
remoteManifestDir, err = p.uploadManifestDir(ui, comm)
|
||||
ui.Message(fmt.Sprintf(
|
||||
"Uploading manifest directory from: %s", p.config.ManifestDir))
|
||||
remoteManifestDir = fmt.Sprintf("%s/manifests", p.config.StagingDir)
|
||||
err := p.uploadDirectory(ui, comm, remoteManifestDir, p.config.ManifestDir)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error uploading manifest dir: %s", err)
|
||||
}
|
||||
|
@ -298,22 +301,6 @@ func (p *Provisioner) uploadHieraConfig(ui packer.Ui, comm packer.Communicator)
|
|||
return path, nil
|
||||
}
|
||||
|
||||
func (p *Provisioner) uploadManifestDir(ui packer.Ui, comm packer.Communicator) (string, error) {
|
||||
ui.Message("Uploading manifest dir...")
|
||||
path, err := os.Open(p.config.ManifestDir)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer path.Close()
|
||||
|
||||
targetPath := fmt.Sprintf("%s/manifests", p.config.StagingDir)
|
||||
if err := p.uploadDirectory(ui, comm, targetPath, p.config.ManifestDir); err != nil {
|
||||
return "", fmt.Errorf("Error uploading manifest dir: %s", err)
|
||||
}
|
||||
|
||||
return targetPath, nil
|
||||
}
|
||||
|
||||
func (p *Provisioner) uploadManifests(ui packer.Ui, comm packer.Communicator) (string, error) {
|
||||
// Create the remote manifests directory...
|
||||
ui.Message("Uploading manifests...")
|
||||
|
|
|
@ -58,13 +58,14 @@ Optional parameters:
|
|||
configuration to be uploaded to the remote machine. Hiera data directories
|
||||
must be uploaded using the file provisioner separately.
|
||||
|
||||
* `manifest_dir` (string) - The path to a local directory with manifests
|
||||
to be uploaded to the remote machine. This is useful if your main
|
||||
manifest file uses imports.
|
||||
|
||||
* `module_paths` (array of strings) - This is an array of paths to module
|
||||
directories on your local filesystem. These will be uploaded to the remote
|
||||
machine. By default, this is empty.
|
||||
|
||||
* `manifest_dir` (string) - The path to a local directory with
|
||||
manifests to be uploaded to the remote machine.
|
||||
|
||||
* `prevent_sudo` (boolean) - By default, the configured commands that are
|
||||
executed to run Puppet are executed with `sudo`. If this is true,
|
||||
then the sudo will be omitted.
|
||||
|
|
Loading…
Reference in New Issue