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
e72c06a7
Commit
e72c06a7
authored
Aug 27, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provisioner/chef-solo: upload cookbooks
parent
607372f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
8 deletions
+35
-8
provisioner/chef-solo/provisioner.go
provisioner/chef-solo/provisioner.go
+35
-8
No files found.
provisioner/chef-solo/provisioner.go
View file @
e72c06a7
...
...
@@ -111,13 +111,21 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
}
}
if
err
:=
p
.
create
StagingDir
(
ui
,
comm
);
err
!=
nil
{
if
err
:=
p
.
create
Dir
(
ui
,
comm
,
p
.
config
.
StagingDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Error creating staging directory: %s"
,
err
)
}
// TODO(mitchellh): Upload cookbooks
cookbookPaths
:=
make
([]
string
,
0
,
len
(
p
.
config
.
CookbookPaths
))
for
i
,
path
:=
range
p
.
config
.
CookbookPaths
{
targetPath
:=
fmt
.
Sprintf
(
"%s/cookbooks-%d"
,
p
.
config
.
StagingDir
,
i
)
if
err
:=
p
.
uploadDirectory
(
ui
,
comm
,
targetPath
,
path
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Error uploading cookbooks: %s"
,
err
)
}
cookbookPaths
=
append
(
cookbookPaths
,
targetPath
)
}
configPath
,
err
:=
p
.
createConfig
(
ui
,
comm
)
configPath
,
err
:=
p
.
createConfig
(
ui
,
comm
,
cookbookPaths
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error creating Chef config file: %s"
,
err
)
}
...
...
@@ -134,14 +142,33 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
return
nil
}
func
(
p
*
Provisioner
)
createConfig
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
(
string
,
error
)
{
func
(
p
*
Provisioner
)
uploadDirectory
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
,
dst
string
,
src
string
)
error
{
if
err
:=
p
.
createDir
(
ui
,
comm
,
dst
);
err
!=
nil
{
return
err
}
// Make sure there is a trailing "/" so that the directory isn't
// created on the other side.
if
src
[
len
(
src
)
-
1
]
!=
'/'
{
src
=
src
+
"/"
}
return
comm
.
UploadDir
(
dst
,
src
,
nil
)
}
func
(
p
*
Provisioner
)
createConfig
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
,
localCookbooks
[]
string
)
(
string
,
error
)
{
ui
.
Message
(
"Creating configuration file 'solo.rb'"
)
cookbook_paths
:=
make
([]
string
,
len
(
p
.
config
.
RemoteCookbookPaths
))
cookbook_paths
:=
make
([]
string
,
len
(
p
.
config
.
RemoteCookbookPaths
)
+
len
(
localCookbooks
)
)
for
i
,
path
:=
range
p
.
config
.
RemoteCookbookPaths
{
cookbook_paths
[
i
]
=
fmt
.
Sprintf
(
`"%s"`
,
path
)
}
for
i
,
path
:=
range
localCookbooks
{
i
=
len
(
p
.
config
.
RemoteCookbookPaths
)
+
i
cookbook_paths
[
i
]
=
fmt
.
Sprintf
(
`"%s"`
,
path
)
}
configString
,
err
:=
p
.
config
.
tpl
.
Process
(
DefaultConfigTemplate
,
&
ConfigTemplate
{
CookbookPaths
:
strings
.
Join
(
cookbook_paths
,
","
),
})
...
...
@@ -186,10 +213,10 @@ func (p *Provisioner) createJson(ui packer.Ui, comm packer.Communicator) (string
return
remotePath
,
nil
}
func
(
p
*
Provisioner
)
create
StagingDir
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
error
{
ui
.
Message
(
fmt
.
Sprintf
(
"Creating
staging directory: %s"
,
p
.
config
.
StagingD
ir
))
func
(
p
*
Provisioner
)
create
Dir
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
,
dir
string
)
error
{
ui
.
Message
(
fmt
.
Sprintf
(
"Creating
directory: %s"
,
d
ir
))
cmd
:=
&
packer
.
RemoteCmd
{
Command
:
fmt
.
Sprintf
(
"mkdir -p '%s'"
,
p
.
config
.
StagingD
ir
),
Command
:
fmt
.
Sprintf
(
"mkdir -p '%s'"
,
d
ir
),
}
if
err
:=
cmd
.
StartWithUi
(
comm
,
ui
);
err
!=
nil
{
...
...
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