Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
5c06af87
Commit
5c06af87
authored
Apr 09, 2015
by
Ameir Abdeldayem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support chef-client 'client_key' and default to <staging
dir>/client.pem.
parent
b49d74d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
provisioner/chef-client/provisioner.go
provisioner/chef-client/provisioner.go
+11
-2
No files found.
provisioner/chef-client/provisioner.go
View file @
5c06af87
...
...
@@ -35,6 +35,7 @@ type Config struct {
SkipCleanNode
bool
`mapstructure:"skip_clean_node"`
SkipInstall
bool
`mapstructure:"skip_install"`
StagingDir
string
`mapstructure:"staging_directory"`
ClientKey
string
`mapstructure:"client_key"`
ValidationKeyPath
string
`mapstructure:"validation_key_path"`
ValidationClientName
string
`mapstructure:"validation_client_name"`
...
...
@@ -48,6 +49,7 @@ type Provisioner struct {
type
ConfigTemplate
struct
{
NodeName
string
ServerUrl
string
ClientKey
string
ValidationKeyPath
string
ValidationClientName
string
ChefEnvironment
string
...
...
@@ -88,6 +90,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
"chef_server_url"
:
&
p
.
config
.
ServerUrl
,
"execute_command"
:
&
p
.
config
.
ExecuteCommand
,
"install_command"
:
&
p
.
config
.
InstallCommand
,
"client_key"
:
&
p
.
config
.
ClientKey
,
"validation_key_path"
:
&
p
.
config
.
ValidationKeyPath
,
"validation_client_name"
:
&
p
.
config
.
ValidationClientName
,
}
...
...
@@ -209,6 +212,10 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
return
fmt
.
Errorf
(
"Error creating staging directory: %s"
,
err
)
}
if
p
.
config
.
ClientKey
==
""
{
p
.
config
.
ClientKey
=
fmt
.
Sprintf
(
"%s/client.pem"
,
p
.
config
.
StagingDir
)
}
if
p
.
config
.
ValidationKeyPath
!=
""
{
remoteValidationKeyPath
=
fmt
.
Sprintf
(
"%s/validation.pem"
,
p
.
config
.
StagingDir
)
if
err
:=
p
.
copyValidationKey
(
ui
,
comm
,
remoteValidationKeyPath
);
err
!=
nil
{
...
...
@@ -217,7 +224,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
}
configPath
,
err
:=
p
.
createConfig
(
ui
,
comm
,
nodeName
,
serverUrl
,
remoteValidationKeyPath
,
p
.
config
.
ValidationClientName
,
p
.
config
.
ChefEnvironment
,
p
.
config
.
SslVerifyMode
)
ui
,
comm
,
nodeName
,
serverUrl
,
p
.
config
.
ClientKey
,
remoteValidationKeyPath
,
p
.
config
.
ValidationClientName
,
p
.
config
.
ChefEnvironment
,
p
.
config
.
SslVerifyMode
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error creating Chef config file: %s"
,
err
)
}
...
...
@@ -271,7 +278,7 @@ func (p *Provisioner) uploadDirectory(ui packer.Ui, comm packer.Communicator, ds
return
comm
.
UploadDir
(
dst
,
src
,
nil
)
}
func
(
p
*
Provisioner
)
createConfig
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
,
nodeName
string
,
serverUrl
string
,
remoteKeyPath
string
,
validationClientName
string
,
chefEnvironment
string
,
sslVerifyMode
string
)
(
string
,
error
)
{
func
(
p
*
Provisioner
)
createConfig
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
,
nodeName
string
,
serverUrl
string
,
clientKey
string
,
remoteKeyPath
string
,
validationClientName
string
,
chefEnvironment
string
,
sslVerifyMode
string
)
(
string
,
error
)
{
ui
.
Message
(
"Creating configuration file 'client.rb'"
)
// Read the template
...
...
@@ -294,6 +301,7 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, nodeN
configString
,
err
:=
p
.
config
.
tpl
.
Process
(
tpl
,
&
ConfigTemplate
{
NodeName
:
nodeName
,
ServerUrl
:
serverUrl
,
ClientKey
:
clientKey
,
ValidationKeyPath
:
remoteKeyPath
,
ValidationClientName
:
validationClientName
,
ChefEnvironment
:
chefEnvironment
,
...
...
@@ -566,6 +574,7 @@ var DefaultConfigTemplate = `
log_level :info
log_location STDOUT
chef_server_url "{{.ServerUrl}}"
client_key "{{.ClientKey}}"
{{if ne .ValidationClientName ""}}
validation_client_name "{{.ValidationClientName}}"
{{else}}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment