Add ability to skip chef registration

This change allows a user to skip the bootstrap stage for a machine.
This commit is contained in:
Sam Dunne 2016-09-29 14:37:48 +01:00 committed by Sander van Harmelen
parent c307dc9557
commit 628743b24c
2 changed files with 16 additions and 9 deletions

View File

@ -104,6 +104,7 @@ type Provisioner struct {
SecretKey string `mapstructure:"secret_key"` SecretKey string `mapstructure:"secret_key"`
ServerURL string `mapstructure:"server_url"` ServerURL string `mapstructure:"server_url"`
SkipInstall bool `mapstructure:"skip_install"` SkipInstall bool `mapstructure:"skip_install"`
SkipRegister bool `mapstructure:"skip_register"`
SSLVerifyMode string `mapstructure:"ssl_verify_mode"` SSLVerifyMode string `mapstructure:"ssl_verify_mode"`
UserName string `mapstructure:"user_name"` UserName string `mapstructure:"user_name"`
UserKey string `mapstructure:"user_key"` UserKey string `mapstructure:"user_key"`
@ -213,18 +214,20 @@ func (r *ResourceProvisioner) Apply(
return err return err
} }
if p.FetchChefCertificates { if !p.SkipRegister {
o.Output("Fetch Chef certificates...") if p.FetchChefCertificates {
if err := p.fetchChefCertificates(o, comm); err != nil { o.Output("Fetch Chef certificates...")
if err := p.fetchChefCertificates(o, comm); err != nil {
return err
}
}
o.Output("Generate the private key...")
if err := p.generateClientKey(o, comm); err != nil {
return err return err
} }
} }
o.Output("Generate the private key...")
if err := p.generateClientKey(o, comm); err != nil {
return err
}
if p.VaultJSON != "" { if p.VaultJSON != "" {
o.Output("Configure Chef vaults...") o.Output("Configure Chef vaults...")
if err := p.configureVaults(o, comm); err != nil { if err := p.configureVaults(o, comm); err != nil {

View File

@ -115,13 +115,17 @@ The following arguments are supported:
machine. This assumes Chef Client is already installed when you run the `chef` machine. This assumes Chef Client is already installed when you run the `chef`
provisioner. provisioner.
* `skip_register (boolean)` - (Optional) Skip the registration of Chef Client on the remote
machine. This assumes Chef Client is already registered when you run the `chef`
provisioner.
* `ssl_verify_mode (string)` - (Optional) Use to set the verify mode for Chef Client HTTPS * `ssl_verify_mode (string)` - (Optional) Use to set the verify mode for Chef Client HTTPS
requests. requests.
* `user_name (string)` - (Required) The name of an existing Chef user to use for registering * `user_name (string)` - (Required) The name of an existing Chef user to use for registering
the new Chef Client and (optionally) configure Chef Vaults. the new Chef Client and (optionally) configure Chef Vaults.
* `user_key (string)` - (Required) The contents of the user key that will be used to * `user_key (string)` - (Required) The contents of the user key that will be used to
authenticate with the Chef Server. This can be loaded from a file on disk using the [`file()` authenticate with the Chef Server. This can be loaded from a file on disk using the [`file()`
interpolation function](/docs/configuration/interpolation.html#file_path_). interpolation function](/docs/configuration/interpolation.html#file_path_).