mirror of
https://github.com/hashicorp/packer.git
synced 2026-10-11 00:41:38 -04:00
Remove Puppet components and docs
This commit is contained in:
@@ -54,8 +54,6 @@ import (
|
||||
fileprovisioner "github.com/hashicorp/packer/provisioner/file"
|
||||
inspecprovisioner "github.com/hashicorp/packer/provisioner/inspec"
|
||||
powershellprovisioner "github.com/hashicorp/packer/provisioner/powershell"
|
||||
puppetmasterlessprovisioner "github.com/hashicorp/packer/provisioner/puppet-masterless"
|
||||
puppetserverprovisioner "github.com/hashicorp/packer/provisioner/puppet-server"
|
||||
saltmasterlessprovisioner "github.com/hashicorp/packer/provisioner/salt-masterless"
|
||||
shellprovisioner "github.com/hashicorp/packer/provisioner/shell"
|
||||
shelllocalprovisioner "github.com/hashicorp/packer/provisioner/shell-local"
|
||||
@@ -102,8 +100,6 @@ var Provisioners = map[string]packersdk.Provisioner{
|
||||
"file": new(fileprovisioner.Provisioner),
|
||||
"inspec": new(inspecprovisioner.Provisioner),
|
||||
"powershell": new(powershellprovisioner.Provisioner),
|
||||
"puppet-masterless": new(puppetmasterlessprovisioner.Provisioner),
|
||||
"puppet-server": new(puppetserverprovisioner.Provisioner),
|
||||
"salt-masterless": new(saltmasterlessprovisioner.Provisioner),
|
||||
"shell": new(shellprovisioner.Provisioner),
|
||||
"shell-local": new(shelllocalprovisioner.Provisioner),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,77 +0,0 @@
|
||||
// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT.
|
||||
|
||||
package puppetmasterless
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/hcl/v2/hcldec"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
// FlatConfig is an auto-generated flat version of Config.
|
||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||
type FlatConfig struct {
|
||||
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"`
|
||||
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"`
|
||||
PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"`
|
||||
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"`
|
||||
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"`
|
||||
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"`
|
||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"`
|
||||
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"`
|
||||
CleanStagingDir *bool `mapstructure:"clean_staging_directory" cty:"clean_staging_directory" hcl:"clean_staging_directory"`
|
||||
GuestOSType *string `mapstructure:"guest_os_type" cty:"guest_os_type" hcl:"guest_os_type"`
|
||||
ExecuteCommand *string `mapstructure:"execute_command" cty:"execute_command" hcl:"execute_command"`
|
||||
ExtraArguments []string `mapstructure:"extra_arguments" cty:"extra_arguments" hcl:"extra_arguments"`
|
||||
Facter map[string]string `cty:"facter" hcl:"facter"`
|
||||
HieraConfigPath *string `mapstructure:"hiera_config_path" cty:"hiera_config_path" hcl:"hiera_config_path"`
|
||||
IgnoreExitCodes *bool `mapstructure:"ignore_exit_codes" cty:"ignore_exit_codes" hcl:"ignore_exit_codes"`
|
||||
ModulePaths []string `mapstructure:"module_paths" cty:"module_paths" hcl:"module_paths"`
|
||||
ManifestFile *string `mapstructure:"manifest_file" cty:"manifest_file" hcl:"manifest_file"`
|
||||
ManifestDir *string `mapstructure:"manifest_dir" cty:"manifest_dir" hcl:"manifest_dir"`
|
||||
PreventSudo *bool `mapstructure:"prevent_sudo" cty:"prevent_sudo" hcl:"prevent_sudo"`
|
||||
PuppetBinDir *string `mapstructure:"puppet_bin_dir" cty:"puppet_bin_dir" hcl:"puppet_bin_dir"`
|
||||
StagingDir *string `mapstructure:"staging_directory" cty:"staging_directory" hcl:"staging_directory"`
|
||||
WorkingDir *string `mapstructure:"working_directory" cty:"working_directory" hcl:"working_directory"`
|
||||
ElevatedUser *string `mapstructure:"elevated_user" cty:"elevated_user" hcl:"elevated_user"`
|
||||
ElevatedPassword *string `mapstructure:"elevated_password" cty:"elevated_password" hcl:"elevated_password"`
|
||||
}
|
||||
|
||||
// FlatMapstructure returns a new FlatConfig.
|
||||
// FlatConfig is an auto-generated flat version of Config.
|
||||
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||
func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||
return new(FlatConfig)
|
||||
}
|
||||
|
||||
// HCL2Spec returns the hcl spec of a Config.
|
||||
// This spec is used by HCL to read the fields of Config.
|
||||
// The decoded values from this spec will then be applied to a FlatConfig.
|
||||
func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
||||
s := map[string]hcldec.Spec{
|
||||
"packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false},
|
||||
"packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false},
|
||||
"packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false},
|
||||
"packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false},
|
||||
"packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false},
|
||||
"packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false},
|
||||
"packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false},
|
||||
"packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false},
|
||||
"clean_staging_directory": &hcldec.AttrSpec{Name: "clean_staging_directory", Type: cty.Bool, Required: false},
|
||||
"guest_os_type": &hcldec.AttrSpec{Name: "guest_os_type", Type: cty.String, Required: false},
|
||||
"execute_command": &hcldec.AttrSpec{Name: "execute_command", Type: cty.String, Required: false},
|
||||
"extra_arguments": &hcldec.AttrSpec{Name: "extra_arguments", Type: cty.List(cty.String), Required: false},
|
||||
"facter": &hcldec.AttrSpec{Name: "facter", Type: cty.Map(cty.String), Required: false},
|
||||
"hiera_config_path": &hcldec.AttrSpec{Name: "hiera_config_path", Type: cty.String, Required: false},
|
||||
"ignore_exit_codes": &hcldec.AttrSpec{Name: "ignore_exit_codes", Type: cty.Bool, Required: false},
|
||||
"module_paths": &hcldec.AttrSpec{Name: "module_paths", Type: cty.List(cty.String), Required: false},
|
||||
"manifest_file": &hcldec.AttrSpec{Name: "manifest_file", Type: cty.String, Required: false},
|
||||
"manifest_dir": &hcldec.AttrSpec{Name: "manifest_dir", Type: cty.String, Required: false},
|
||||
"prevent_sudo": &hcldec.AttrSpec{Name: "prevent_sudo", Type: cty.Bool, Required: false},
|
||||
"puppet_bin_dir": &hcldec.AttrSpec{Name: "puppet_bin_dir", Type: cty.String, Required: false},
|
||||
"staging_directory": &hcldec.AttrSpec{Name: "staging_directory", Type: cty.String, Required: false},
|
||||
"working_directory": &hcldec.AttrSpec{Name: "working_directory", Type: cty.String, Required: false},
|
||||
"elevated_user": &hcldec.AttrSpec{Name: "elevated_user", Type: cty.String, Required: false},
|
||||
"elevated_password": &hcldec.AttrSpec{Name: "elevated_password", Type: cty.String, Required: false},
|
||||
}
|
||||
return s
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/packer-plugin-sdk/version"
|
||||
packerVersion "github.com/hashicorp/packer/version"
|
||||
)
|
||||
|
||||
var PuppetMasterlessPluginVersion *version.PluginVersion
|
||||
|
||||
func init() {
|
||||
PuppetMasterlessPluginVersion = version.InitializePluginVersion(
|
||||
packerVersion.Version, packerVersion.VersionPrerelease)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,77 +0,0 @@
|
||||
// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT.
|
||||
|
||||
package puppetserver
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/hcl/v2/hcldec"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
// FlatConfig is an auto-generated flat version of Config.
|
||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||
type FlatConfig struct {
|
||||
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"`
|
||||
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"`
|
||||
PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"`
|
||||
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"`
|
||||
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"`
|
||||
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"`
|
||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"`
|
||||
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"`
|
||||
CleanStagingDir *bool `mapstructure:"clean_staging_directory" cty:"clean_staging_directory" hcl:"clean_staging_directory"`
|
||||
ClientCertPath *string `mapstructure:"client_cert_path" cty:"client_cert_path" hcl:"client_cert_path"`
|
||||
ClientPrivateKeyPath *string `mapstructure:"client_private_key_path" cty:"client_private_key_path" hcl:"client_private_key_path"`
|
||||
ExecuteCommand *string `mapstructure:"execute_command" cty:"execute_command" hcl:"execute_command"`
|
||||
ExtraArguments []string `mapstructure:"extra_arguments" cty:"extra_arguments" hcl:"extra_arguments"`
|
||||
Facter map[string]string `cty:"facter" hcl:"facter"`
|
||||
GuestOSType *string `mapstructure:"guest_os_type" cty:"guest_os_type" hcl:"guest_os_type"`
|
||||
IgnoreExitCodes *bool `mapstructure:"ignore_exit_codes" cty:"ignore_exit_codes" hcl:"ignore_exit_codes"`
|
||||
PreventSudo *bool `mapstructure:"prevent_sudo" cty:"prevent_sudo" hcl:"prevent_sudo"`
|
||||
PuppetBinDir *string `mapstructure:"puppet_bin_dir" cty:"puppet_bin_dir" hcl:"puppet_bin_dir"`
|
||||
PuppetNode *string `mapstructure:"puppet_node" cty:"puppet_node" hcl:"puppet_node"`
|
||||
PuppetServer *string `mapstructure:"puppet_server" cty:"puppet_server" hcl:"puppet_server"`
|
||||
StagingDir *string `mapstructure:"staging_dir" cty:"staging_dir" hcl:"staging_dir"`
|
||||
WorkingDir *string `mapstructure:"working_directory" cty:"working_directory" hcl:"working_directory"`
|
||||
ElevatedUser *string `mapstructure:"elevated_user" cty:"elevated_user" hcl:"elevated_user"`
|
||||
ElevatedPassword *string `mapstructure:"elevated_password" cty:"elevated_password" hcl:"elevated_password"`
|
||||
}
|
||||
|
||||
// FlatMapstructure returns a new FlatConfig.
|
||||
// FlatConfig is an auto-generated flat version of Config.
|
||||
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||
func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||
return new(FlatConfig)
|
||||
}
|
||||
|
||||
// HCL2Spec returns the hcl spec of a Config.
|
||||
// This spec is used by HCL to read the fields of Config.
|
||||
// The decoded values from this spec will then be applied to a FlatConfig.
|
||||
func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
||||
s := map[string]hcldec.Spec{
|
||||
"packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false},
|
||||
"packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false},
|
||||
"packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false},
|
||||
"packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false},
|
||||
"packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false},
|
||||
"packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false},
|
||||
"packer_user_variables": &hcldec.AttrSpec{Name: "packer_user_variables", Type: cty.Map(cty.String), Required: false},
|
||||
"packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false},
|
||||
"clean_staging_directory": &hcldec.AttrSpec{Name: "clean_staging_directory", Type: cty.Bool, Required: false},
|
||||
"client_cert_path": &hcldec.AttrSpec{Name: "client_cert_path", Type: cty.String, Required: false},
|
||||
"client_private_key_path": &hcldec.AttrSpec{Name: "client_private_key_path", Type: cty.String, Required: false},
|
||||
"execute_command": &hcldec.AttrSpec{Name: "execute_command", Type: cty.String, Required: false},
|
||||
"extra_arguments": &hcldec.AttrSpec{Name: "extra_arguments", Type: cty.List(cty.String), Required: false},
|
||||
"facter": &hcldec.AttrSpec{Name: "facter", Type: cty.Map(cty.String), Required: false},
|
||||
"guest_os_type": &hcldec.AttrSpec{Name: "guest_os_type", Type: cty.String, Required: false},
|
||||
"ignore_exit_codes": &hcldec.AttrSpec{Name: "ignore_exit_codes", Type: cty.Bool, Required: false},
|
||||
"prevent_sudo": &hcldec.AttrSpec{Name: "prevent_sudo", Type: cty.Bool, Required: false},
|
||||
"puppet_bin_dir": &hcldec.AttrSpec{Name: "puppet_bin_dir", Type: cty.String, Required: false},
|
||||
"puppet_node": &hcldec.AttrSpec{Name: "puppet_node", Type: cty.String, Required: false},
|
||||
"puppet_server": &hcldec.AttrSpec{Name: "puppet_server", Type: cty.String, Required: false},
|
||||
"staging_dir": &hcldec.AttrSpec{Name: "staging_dir", Type: cty.String, Required: false},
|
||||
"working_directory": &hcldec.AttrSpec{Name: "working_directory", Type: cty.String, Required: false},
|
||||
"elevated_user": &hcldec.AttrSpec{Name: "elevated_user", Type: cty.String, Required: false},
|
||||
"elevated_password": &hcldec.AttrSpec{Name: "elevated_password", Type: cty.String, Required: false},
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
package puppetserver
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
)
|
||||
|
||||
func testConfig() (config map[string]interface{}, tf *os.File) {
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
config = map[string]interface{}{
|
||||
"puppet_server": tf.Name(),
|
||||
}
|
||||
|
||||
return config, tf
|
||||
}
|
||||
|
||||
func TestProvisioner_Impl(t *testing.T) {
|
||||
var raw interface{}
|
||||
raw = &Provisioner{}
|
||||
if _, ok := raw.(packersdk.Provisioner); !ok {
|
||||
t.Fatalf("must be a Provisioner")
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerPrepare_puppetBinDir(t *testing.T) {
|
||||
config, tempfile := testConfig()
|
||||
defer os.Remove(tempfile.Name())
|
||||
defer tempfile.Close()
|
||||
|
||||
delete(config, "puppet_bin_dir")
|
||||
p := new(Provisioner)
|
||||
err := p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
defer os.Remove(tf.Name())
|
||||
|
||||
config["puppet_bin_dir"] = tf.Name()
|
||||
p = new(Provisioner)
|
||||
err = p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerPrepare_clientPrivateKeyPath(t *testing.T) {
|
||||
config, tempfile := testConfig()
|
||||
defer os.Remove(tempfile.Name())
|
||||
defer tempfile.Close()
|
||||
|
||||
delete(config, "client_private_key_path")
|
||||
p := new(Provisioner)
|
||||
err := p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
// Test with bad paths
|
||||
config["client_private_key_path"] = "i-should-not-exist"
|
||||
p = new(Provisioner)
|
||||
err = p.Prepare(config)
|
||||
if err == nil {
|
||||
t.Fatal("should be an error")
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
td, err := ioutil.TempDir("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error: %s", err)
|
||||
}
|
||||
defer os.RemoveAll(td)
|
||||
|
||||
config["client_private_key_path"] = td
|
||||
p = new(Provisioner)
|
||||
err = p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerPrepare_clientCertPath(t *testing.T) {
|
||||
config, tempfile := testConfig()
|
||||
defer os.Remove(tempfile.Name())
|
||||
defer tempfile.Close()
|
||||
|
||||
delete(config, "client_cert_path")
|
||||
p := new(Provisioner)
|
||||
err := p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
// Test with bad paths
|
||||
config["client_cert_path"] = "i-should-not-exist"
|
||||
p = new(Provisioner)
|
||||
err = p.Prepare(config)
|
||||
if err == nil {
|
||||
t.Fatal("should be an error")
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
td, err := ioutil.TempDir("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error: %s", err)
|
||||
}
|
||||
defer os.RemoveAll(td)
|
||||
|
||||
config["client_cert_path"] = td
|
||||
p = new(Provisioner)
|
||||
err = p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerPrepare_executeCommand(t *testing.T) {
|
||||
config, tempfile := testConfig()
|
||||
defer os.Remove(tempfile.Name())
|
||||
defer tempfile.Close()
|
||||
|
||||
delete(config, "execute_command")
|
||||
p := new(Provisioner)
|
||||
err := p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerPrepare_facterFacts(t *testing.T) {
|
||||
config, tempfile := testConfig()
|
||||
defer os.Remove(tempfile.Name())
|
||||
defer tempfile.Close()
|
||||
|
||||
delete(config, "facter")
|
||||
p := new(Provisioner)
|
||||
err := p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
// Test with malformed fact
|
||||
config["facter"] = "fact=stringified"
|
||||
p = new(Provisioner)
|
||||
err = p.Prepare(config)
|
||||
if err == nil {
|
||||
t.Fatal("should be an error")
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
td, err := ioutil.TempDir("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error: %s", err)
|
||||
}
|
||||
defer os.RemoveAll(td)
|
||||
|
||||
facts := make(map[string]string)
|
||||
facts["fact_name"] = "fact_value"
|
||||
config["facter"] = facts
|
||||
|
||||
p = new(Provisioner)
|
||||
err = p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
// Make sure the default facts are present
|
||||
delete(config, "facter")
|
||||
p = new(Provisioner)
|
||||
err = p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if p.config.Facter == nil {
|
||||
t.Fatalf("err: Default facts are not set in the Puppet provisioner!")
|
||||
}
|
||||
|
||||
if _, ok := p.config.Facter["packer_build_name"]; !ok {
|
||||
t.Fatalf("err: packer_build_name fact not set in the Puppet provisioner!")
|
||||
}
|
||||
|
||||
if _, ok := p.config.Facter["packer_builder_type"]; !ok {
|
||||
t.Fatalf("err: packer_builder_type fact not set in the Puppet provisioner!")
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvisionerPrepare_stagingDir(t *testing.T) {
|
||||
config, tempfile := testConfig()
|
||||
defer os.Remove(tempfile.Name())
|
||||
defer tempfile.Close()
|
||||
|
||||
delete(config, "staging_dir")
|
||||
p := new(Provisioner)
|
||||
err := p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
// Make sure the default staging directory is correct
|
||||
if p.config.StagingDir != "/tmp/packer-puppet-server" {
|
||||
t.Fatalf("err: Default staging_dir is not set in the Puppet provisioner!")
|
||||
}
|
||||
|
||||
// Make sure default staging directory can be overridden
|
||||
config["staging_dir"] = "/tmp/override"
|
||||
p = new(Provisioner)
|
||||
err = p.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if p.config.StagingDir != "/tmp/override" {
|
||||
t.Fatalf("err: Overridden staging_dir is not set correctly in the Puppet provisioner!")
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/packer-plugin-sdk/version"
|
||||
packerVersion "github.com/hashicorp/packer/version"
|
||||
)
|
||||
|
||||
var PuppetServerPluginVersion *version.PluginVersion
|
||||
|
||||
func init() {
|
||||
PuppetServerPluginVersion = version.InitializePluginVersion(
|
||||
packerVersion.Version, packerVersion.VersionPrerelease)
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
---
|
||||
description: >
|
||||
The masterless Puppet Packer provisioner configures Puppet to run on the
|
||||
|
||||
machines by Packer from local modules and manifest files. Modules and
|
||||
manifests
|
||||
|
||||
can be uploaded from your local machine to the remote machine or can simply
|
||||
use
|
||||
|
||||
remote paths. Puppet is run in masterless mode, meaning it never communicates
|
||||
|
||||
to a Puppet master.
|
||||
page_title: Puppet Masterless - Provisioners
|
||||
---
|
||||
|
||||
# Puppet (Masterless) Provisioner
|
||||
|
||||
@include 'provisioners/unmaintained-plugin.mdx'
|
||||
|
||||
Type: `puppet-masterless`
|
||||
|
||||
The masterless Puppet Packer provisioner configures Puppet to run on the
|
||||
machines by Packer from local modules and manifest files. Modules and manifests
|
||||
can be uploaded from your local machine to the remote machine or can simply use
|
||||
remote paths (perhaps obtained using something like the shell provisioner).
|
||||
Puppet is run in masterless mode, meaning it never communicates to a Puppet
|
||||
master.
|
||||
|
||||
-> **Note:** Puppet will _not_ be installed automatically by this
|
||||
provisioner. This provisioner expects that Puppet is already installed on the
|
||||
machine. It is common practice to use the [shell
|
||||
provisioner](/docs/provisioners/shell) before the Puppet provisioner to do
|
||||
this.
|
||||
|
||||
## Basic Example
|
||||
|
||||
The example below is fully functional and expects the configured manifest file
|
||||
to exist relative to your working directory.
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "puppet-masterless",
|
||||
"manifest_file": "site.pp"
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration Reference
|
||||
|
||||
The reference of available configuration options is listed below.
|
||||
|
||||
Required parameters:
|
||||
|
||||
- `manifest_file` (string) - This is either a path to a puppet manifest
|
||||
(`.pp` file) _or_ a directory containing multiple manifests that puppet
|
||||
will apply (the ["main
|
||||
manifest"](https://docs.puppetlabs.com/puppet/latest/reference/dirs_manifest)).
|
||||
These file(s) must exist on your local system and will be uploaded to the
|
||||
remote machine.
|
||||
|
||||
Optional parameters:
|
||||
|
||||
- `execute_command` (string) - The command-line to execute Puppet. This is a
|
||||
[template engine](/docs/templates/legacy_json_templates/engine). Therefore, you
|
||||
may use user variables and template functions in this field. In addition,
|
||||
you may use the following extra variables:
|
||||
- FacterVars: Additional facts to set when executing Puppet, joined for
|
||||
use in a command. This is internal and not settable by the user.
|
||||
- HieraConfigPath: Path to a hiera configuration file to upload and use;
|
||||
set in the template option hiera_config_path
|
||||
- ManifestDir: The directory of the manifest file on the remote machine.
|
||||
- ManifestFile: The manifest file on the remote machine.
|
||||
- ModulePath: The module_paths, combined into one path variable.
|
||||
- ModulePathJoiner: A colon `:` on posix systems and a semicolon `;` on
|
||||
Windows.
|
||||
- PuppetBinDir: The directory that the Puppet binary is in.
|
||||
- Sudo: Returns false when PreventSudo is set, and true when it is not.
|
||||
- WorkingDir: The value provided in the `working_directory` option.
|
||||
See below for `execute_command`'s default value.
|
||||
|
||||
* `extra_arguments` (array of strings) - Additional options to pass to the
|
||||
Puppet command. This allows for customization of
|
||||
`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
|
||||
template variables as well as private elements of ExecuteTemplate (see
|
||||
source: provisioner/puppet-masterless/provisioner.go).
|
||||
|
||||
```text
|
||||
[
|
||||
{{if ne "{{user environment}}" ""}}--environment={{user environment}}{{end}},
|
||||
{{if ne ".ModulePath" ""}}--modulepath="{{.ModulePath}}{{.ModulePathJoiner}}$(puppet config print {{if ne "{{user `environment`}}" ""}}--environment={{user `environment`}}{{end}} modulepath)"{{end}}
|
||||
]
|
||||
```
|
||||
|
||||
* `facter` (object of key:value strings) - Additional
|
||||
[facts](https://docs.puppet.com/facter/) to make available to the Puppet
|
||||
run.
|
||||
|
||||
* `guest_os_type` (string) - The remote host's OS type ('windows' or 'unix')
|
||||
to tailor command-line and path separators. (default: unix).
|
||||
|
||||
* `hiera_config_path` (string) - Local path to self-contained Hiera data to
|
||||
be uploaded. NOTE: If you need data directories they must be previously
|
||||
transferred with a File provisioner.
|
||||
|
||||
* `ignore_exit_codes` (boolean) - If true, Packer will ignore failures.
|
||||
|
||||
* `manifest_dir` (string) - Local directory with manifests to be uploaded.
|
||||
This is useful if your main manifest uses imports, but the directory might
|
||||
not contain the `manifest_file` itself.
|
||||
|
||||
~> `manifest_dir` is passed to Puppet as `--manifestdir` option. This
|
||||
option was deprecated in puppet 3.6, and removed in puppet 4.0. If you have
|
||||
multiple manifests you should use `manifest_file` instead.
|
||||
|
||||
- `module_paths` (array of strings) - Array of local module directories to be
|
||||
uploaded.
|
||||
|
||||
- `prevent_sudo` (boolean) - On Unix platforms Puppet is typically invoked
|
||||
with `sudo`. If true, it will be omitted. (default: false)
|
||||
|
||||
- `puppet_bin_dir` (string) - Path to the Puppet binary. Ideally the program
|
||||
should be on the system (unix: `$PATH`, windows: `%PATH%`), but some
|
||||
builders (eg. Docker) do not run profile-setup scripts and therefore PATH
|
||||
might be empty or minimal. On Windows, spaces should be `^`-escaped, i.e.
|
||||
`c:/program^ files/puppet^ labs/puppet/bin`.
|
||||
|
||||
- `staging_directory` (string) - Directory to where uploaded files will be
|
||||
placed (unix: "/tmp/packer-puppet-masterless", windows:
|
||||
"%SYSTEMROOT%/Temp/packer-puppet-masterless"). It doesn't need to
|
||||
pre-exist, but the parent must have permissions sufficient for the account
|
||||
Packer connects as to create directories and write files. Use a Shell
|
||||
provisioner to prepare the way if needed.
|
||||
|
||||
- `working_directory` (string) - Directory from which `execute_command` will
|
||||
be run. If using Hiera files with relative paths, this option can be
|
||||
helpful. (default: `staging_directory`)
|
||||
|
||||
- `elevated_user` and `elevated_password` (string) - If specified, Puppet
|
||||
will be run with elevated privileges using the given Windows user. See the
|
||||
[powershell](/docs/provisioners/powershell) provisioner for the full
|
||||
details. This is a [template engine](/docs/templates/legacy_json_templates/engine).
|
||||
Therefore, you may use user variables and template functions in this
|
||||
field, including `` {{ build `Password`}} `` to use the password being used
|
||||
by the communicator to connect to your instance.
|
||||
|
||||
@include 'provisioners/common-config.mdx'
|
||||
|
||||
## Execute Command
|
||||
|
||||
By default, Packer uses the following command (broken across multiple lines for
|
||||
readability) to execute Puppet:
|
||||
|
||||
```shell
|
||||
cd {{.WorkingDir}} &&
|
||||
{{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}}
|
||||
{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}
|
||||
{{.ManifestFile}}
|
||||
```
|
||||
|
||||
The following command is used if guest OS type is windows:
|
||||
|
||||
```shell
|
||||
cd {{.WorkingDir}} &&
|
||||
{{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}}
|
||||
{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}
|
||||
{{.ManifestFile}}
|
||||
```
|
||||
|
||||
## Default Facts
|
||||
|
||||
In addition to being able to specify custom Facter facts using the `facter`
|
||||
configuration, the provisioner automatically defines certain commonly useful
|
||||
facts:
|
||||
|
||||
- `packer_build_name` is set to the name of the build that Packer is running.
|
||||
This is most useful when Packer is making multiple builds and you want to
|
||||
distinguish them in your Hiera hierarchy.
|
||||
|
||||
- `packer_builder_type` is the type of the builder that was used to create
|
||||
the machine that Puppet is running on. This is useful if you want to run
|
||||
only certain parts of your Puppet code on systems built with certain
|
||||
builders.
|
||||
@@ -1,176 +0,0 @@
|
||||
---
|
||||
description: |
|
||||
The puppet-server Packer provisioner provisions Packer machines with Puppet by
|
||||
connecting to a Puppet master.
|
||||
page_title: Puppet Server - Provisioners
|
||||
---
|
||||
|
||||
# Puppet Server Provisioner
|
||||
|
||||
@include 'provisioners/unmaintained-plugin.mdx'
|
||||
|
||||
Type: `puppet-server`
|
||||
|
||||
The `puppet-server` Packer provisioner provisions Packer machines with Puppet
|
||||
by connecting to a Puppet master.
|
||||
|
||||
-> **Note:** Puppet will _not_ be installed automatically by this
|
||||
provisioner. This provisioner expects that Puppet is already installed on the
|
||||
machine. It is common practice to use the [shell
|
||||
provisioner](/docs/provisioners/shell) before the Puppet provisioner to do
|
||||
this.
|
||||
|
||||
## Basic Example
|
||||
|
||||
The example below is fully functional and expects a Puppet server to be
|
||||
accessible from your network.
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "puppet-server",
|
||||
"extra_arguments": "--test --pluginsync",
|
||||
"facter": {
|
||||
"server_role": "webserver"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration Reference
|
||||
|
||||
The reference of available configuration options is listed below.
|
||||
|
||||
The provisioner takes various options. None are strictly required. They are
|
||||
listed below:
|
||||
|
||||
- `client_cert_path` (string) - Path to the directory on your disk that
|
||||
contains the client certificate for the node. This defaults to nothing, in
|
||||
which case a client cert won't be uploaded.
|
||||
|
||||
- `client_private_key_path` (string) - Path to the directory on your disk
|
||||
that contains the client private key for the node. This defaults to
|
||||
nothing, in which case a client private key won't be uploaded.
|
||||
|
||||
- `execute_command` (string) - The command-line to execute Puppet. This is a
|
||||
[template engine](/docs/templates/legacy_json_templates/engine). Therefore, you
|
||||
may use user variables and template functions in this field. In addition,
|
||||
you may use the following extra variables:
|
||||
- ClientCertPath: The value set in the template option
|
||||
`client_cert_path`.
|
||||
- ClientPrivateKeyPath: The value set in the template option
|
||||
`client_private_key_path`.
|
||||
- FacterVars: Additional facts to set when executing Puppet, joined for
|
||||
use in a command. This is internal and not settable by the user.
|
||||
- PuppetNode: The hostname of the Puppet node, set in `puppet_node`.
|
||||
- PuppetServer: The hostname of the Puppet server, set in `puppet_server`
|
||||
- PuppetBinDir: The directory that the Puppet binary is in.
|
||||
- Sudo: Returns false when PreventSudo is set, and true when it is not.
|
||||
- WorkingDir: The value provided in the `working_directory` option.
|
||||
See below for `execute_command`'s default value.
|
||||
|
||||
* `extra_arguments` (array of strings) - Additional options to pass to the
|
||||
Puppet command. This allows for customization of `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
|
||||
template variables as well as private elements of ExecuteTemplate (see
|
||||
source: provisioner/puppet-server/provisioner.go).
|
||||
|
||||
```text
|
||||
[
|
||||
{{if ne "{{user environment}}" ""}}--environment={{user environment}}{{end}}
|
||||
]
|
||||
```
|
||||
|
||||
* `facter` (object of key/value strings) - Additional
|
||||
[facts](https://puppet.com/docs/puppet/latest/facter.html) to make available to the Puppet run.
|
||||
|
||||
* `guest_os_type` (string) - The remote host's OS type ('windows' or 'unix')
|
||||
to tailor command-line and path separators. (default: unix).
|
||||
|
||||
* `ignore_exit_codes` (boolean) - If true, Packer will ignore failures.
|
||||
|
||||
* `prevent_sudo` (boolean) - On Unix platforms Puppet is typically invoked
|
||||
with `sudo`. If true, it will be omitted. (default: false)
|
||||
|
||||
* `puppet_bin_dir` (string) - Path to the Puppet binary. Ideally the program
|
||||
should be on the system (unix: `$PATH`, windows: `%PATH%`), but some
|
||||
builders (eg. Docker) do not run profile-setup scripts and therefore PATH
|
||||
might be empty or minimal. On Windows, spaces should be `^`-escaped, i.e.
|
||||
`c:/program^ files/puppet^ labs/puppet/bin`.
|
||||
|
||||
* `puppet_node` (string) - The name of the node. If this isn't set, the fully
|
||||
qualified domain name will be used.
|
||||
|
||||
* `puppet_server` (string) - Hostname of the Puppet server. By default
|
||||
"puppet" will be used.
|
||||
|
||||
* `staging_dir` (string) - Directory to where uploaded files will be placed
|
||||
(unix: "/tmp/packer-puppet-masterless", windows:
|
||||
"%SYSTEMROOT%/Temp/packer-puppet-masterless"). It doesn't need to
|
||||
pre-exist, but the parent must have permissions sufficient for the account
|
||||
Packer connects as to create directories and write files. Use a Shell
|
||||
provisioner to prepare the way if needed.
|
||||
|
||||
* `working_directory` (string) - Directory from which `execute_command` will
|
||||
be run. If using Hiera files with relative paths, this option can be
|
||||
helpful. (default: `staging_directory`)
|
||||
|
||||
* `elevated_user` and `elevated_password` (string) - If specified, Puppet
|
||||
will be run with elevated privileges using the given Windows user. See the
|
||||
[powershell](/docs/provisioners/powershell) provisioner for the full
|
||||
details. This is a [template engine](/docs/templates/legacy_json_templates/engine).
|
||||
Therefore, you may use user variables and template functions in this
|
||||
field, including `` {{ build `Password`}} `` to use the password being used
|
||||
by the communicator to connect to your instance.
|
||||
|
||||
@include 'provisioners/common-config.mdx'
|
||||
|
||||
## Execute Command
|
||||
|
||||
By default, Packer uses the following command (broken across multiple lines for
|
||||
readability) to execute Puppet:
|
||||
|
||||
```shell
|
||||
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}}
|
||||
{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}
|
||||
```
|
||||
|
||||
The following command is used if guest OS type is windows:
|
||||
|
||||
```shell
|
||||
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}}
|
||||
{{if ne .ExtraArguments ""}}{{.ExtraArguments}} {{end}}
|
||||
```
|
||||
|
||||
## Default Facts
|
||||
|
||||
In addition to being able to specify custom Facter facts using the `facter`
|
||||
configuration, the provisioner automatically defines certain commonly useful
|
||||
facts:
|
||||
|
||||
- `packer_build_name` is set to the name of the build that Packer is running.
|
||||
This is most useful when Packer is making multiple builds and you want to
|
||||
distinguish them in your Hiera hierarchy.
|
||||
|
||||
- `packer_builder_type` is the type of the builder that was used to create
|
||||
the machine that Puppet is running on. This is useful if you want to run
|
||||
only certain parts of your Puppet code on systems built with certain
|
||||
builders.
|
||||
@@ -844,14 +844,6 @@
|
||||
"title": "PowerShell",
|
||||
"path": "provisioners/powershell"
|
||||
},
|
||||
{
|
||||
"title": "Puppet Masterless",
|
||||
"path": "provisioners/puppet-masterless"
|
||||
},
|
||||
{
|
||||
"title": "Puppet Server",
|
||||
"path": "provisioners/puppet-server"
|
||||
},
|
||||
{
|
||||
"title": "Salt Masterless",
|
||||
"path": "provisioners/salt-masterless"
|
||||
|
||||
Reference in New Issue
Block a user