add chef secret key
This commit is contained in:
parent
82d142cc5f
commit
6e21ca50a0
|
@ -28,6 +28,7 @@ const (
|
|||
firstBoot = "first-boot.json"
|
||||
logfileDir = "logfiles"
|
||||
linuxConfDir = "/etc/chef"
|
||||
secretKey = "encrypted_data_bag_secret"
|
||||
validationKey = "validation.pem"
|
||||
windowsConfDir = "C:/chef"
|
||||
)
|
||||
|
@ -67,6 +68,7 @@ type Provisioner struct {
|
|||
OSType string `mapstructure:"os_type"`
|
||||
PreventSudo bool `mapstructure:"prevent_sudo"`
|
||||
RunList []string `mapstructure:"run_list"`
|
||||
SecretKeyPath string `mapstructure:"secret_key_path"`
|
||||
ServerURL string `mapstructure:"server_url"`
|
||||
SkipInstall bool `mapstructure:"skip_install"`
|
||||
SSLVerifyMode string `mapstructure:"ssl_verify_mode"`
|
||||
|
@ -346,6 +348,21 @@ func (p *Provisioner) deployConfigFiles(
|
|||
return fmt.Errorf("Uploading %s failed: %v", validationKey, err)
|
||||
}
|
||||
|
||||
if p.SecretKeyPath != nil
|
||||
{
|
||||
// Open the secret key file
|
||||
f, err := os.Open(p.SecretKeyPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
// Copy the secret key to the new instance
|
||||
if err := comm.Upload(path.Join(confDir, secretKey), f); err != nil {
|
||||
return fmt.Errorf("Uploading %s failed: %v", secretKey, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Make strings.Join available for use within the template
|
||||
funcMap := template.FuncMap{
|
||||
"join": strings.Join,
|
||||
|
|
|
@ -21,6 +21,7 @@ func TestResourceProvider_Validate_good(t *testing.T) {
|
|||
"server_url": "https://chef.local",
|
||||
"validation_client_name": "validator",
|
||||
"validation_key_path": "validator.pem",
|
||||
"secret_key_path": "encrypted_data_bag_secret",
|
||||
})
|
||||
r := new(ResourceProvisioner)
|
||||
warn, errs := r.Validate(c)
|
||||
|
@ -68,6 +69,7 @@ func TestResourceProvider_runChefClient(t *testing.T) {
|
|||
"server_url": "https://chef.local",
|
||||
"validation_client_name": "validator",
|
||||
"validation_key_path": "test-fixtures/validator.pem",
|
||||
"secret_key_path": "test-fixtures/encrypted_data_bag_secret",
|
||||
}),
|
||||
|
||||
ConfDir: linuxConfDir,
|
||||
|
@ -85,6 +87,7 @@ func TestResourceProvider_runChefClient(t *testing.T) {
|
|||
"server_url": "https://chef.local",
|
||||
"validation_client_name": "validator",
|
||||
"validation_key_path": "test-fixtures/validator.pem",
|
||||
"secret_key_path": "test-fixtures/encrypted_data_bag_secret",
|
||||
}),
|
||||
|
||||
ConfDir: linuxConfDir,
|
||||
|
@ -103,6 +106,7 @@ func TestResourceProvider_runChefClient(t *testing.T) {
|
|||
"server_url": "https://chef.local",
|
||||
"validation_client_name": "validator",
|
||||
"validation_key_path": "test-fixtures/validator.pem",
|
||||
"secret_key_path": "test-fixtures/encrypted_data_bag_secret",
|
||||
}),
|
||||
|
||||
ConfDir: windowsConfDir,
|
||||
|
|
Loading…
Reference in New Issue