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
9ebf0435
Commit
9ebf0435
authored
May 27, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provisioner/shell: Basic run
parent
33f8d295
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
40 deletions
+30
-40
.gitignore
.gitignore
+1
-0
TODO.md
TODO.md
+1
-0
example.json
example.json
+0
-24
example.toml
example.toml
+0
-15
provisioner/shell/provisioner.go
provisioner/shell/provisioner.go
+28
-1
No files found.
.gitignore
View file @
9ebf0435
/bin
/local
packerrc
TODO.md
View file @
9ebf0435
...
...
@@ -6,5 +6,6 @@
*
packer: Communicator should have Close() method
*
packer: Ui input
*
packer/plugin: Better error messages/detection if plugin crashes
*
packer/plugin: Testing of client struct/methods
*
provisioner/shell: Upload file
*
provisioner/shell: Arguments
example.json
deleted
100644 → 0
View file @
33f8d295
{
"name"
:
"my-custom-image"
,
"builders"
:
[
{
"type"
:
"amazon-ebs"
,
"region"
:
"us-east-1"
,
"source_ami"
:
"ami-de0d9eb7"
}
],
"provisioners"
:
[
{
"type"
:
"shell"
,
"path"
:
"script.sh"
}
],
"outputs"
:
[
{
"type"
:
"vagrant"
}
]
}
example.toml
deleted
100644 → 0
View file @
33f8d295
name
=
"my-custom-image"
[builder.amazon-ebs]
region
=
"us-east-1"
source
=
"ami-de0d9eb7"
[provision]
[provision.shell]
type
=
"shell"
path
=
"script.sh"
[output]
[output.vagrant]
provisioner/shell/provisioner.go
View file @
9ebf0435
...
...
@@ -3,8 +3,11 @@
package
shell
import
(
"fmt"
"github.com/mitchellh/mapstructure"
"github.com/mitchellh/packer/packer"
"log"
"os"
)
const
DefaultRemotePath
=
"/tmp/script.sh"
...
...
@@ -33,5 +36,29 @@ func (p *Provisioner) Prepare(raw interface{}, ui packer.Ui) {
}
func
(
p
*
Provisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
ui
.
Say
(
"PROVISIONING SOME STUFF"
)
log
.
Printf
(
"Opening %s for reading"
,
p
.
config
.
Path
)
f
,
err
:=
os
.
Open
(
p
.
config
.
Path
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error opening shell script: %s"
,
err
))
return
}
log
.
Printf
(
"Uploading %s => %s"
,
p
.
config
.
Path
,
p
.
config
.
RemotePath
)
err
=
comm
.
Upload
(
p
.
config
.
RemotePath
,
f
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error uploading shell script: %s"
,
err
))
return
}
command
:=
fmt
.
Sprintf
(
"chmod +x %s && %s"
,
p
.
config
.
RemotePath
,
p
.
config
.
RemotePath
)
log
.
Printf
(
"Executing command: %s"
,
command
)
cmd
,
err
:=
comm
.
Start
(
command
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Failed executing command: %s"
,
err
))
return
}
ui
.
Say
(
"Waiting for remote command to finish..."
)
cmd
.
Wait
()
ui
.
Say
(
"Command run!"
)
}
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