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
5d2ea088
Commit
5d2ea088
authored
Jun 23, 2015
by
Clint Shryock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon-chroot: add root_volume_size to resize chroot root volume
parent
8a9a59c3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
6 deletions
+24
-6
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+7
-2
builder/amazon/chroot/step_create_volume.go
builder/amazon/chroot/step_create_volume.go
+10
-3
builder/amazon/chroot/step_register_ami.go
builder/amazon/chroot/step_register_ami.go
+7
-1
No files found.
builder/amazon/chroot/builder.go
View file @
5d2ea088
...
@@ -34,6 +34,7 @@ type Config struct {
...
@@ -34,6 +34,7 @@ type Config struct {
DevicePath
string
`mapstructure:"device_path"`
DevicePath
string
`mapstructure:"device_path"`
MountPath
string
`mapstructure:"mount_path"`
MountPath
string
`mapstructure:"mount_path"`
SourceAmi
string
`mapstructure:"source_ami"`
SourceAmi
string
`mapstructure:"source_ami"`
RootVolumeSize
int64
`mapstructure:"root_volume_size"`
ctx
interpolate
.
Context
ctx
interpolate
.
Context
}
}
...
@@ -159,7 +160,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -159,7 +160,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
StepCheckRootDevice
{},
&
StepCheckRootDevice
{},
&
StepFlock
{},
&
StepFlock
{},
&
StepPrepareDevice
{},
&
StepPrepareDevice
{},
&
StepCreateVolume
{},
&
StepCreateVolume
{
RootVolumeSize
:
b
.
config
.
RootVolumeSize
,
},
&
StepAttachVolume
{},
&
StepAttachVolume
{},
&
StepEarlyUnflock
{},
&
StepEarlyUnflock
{},
&
StepMountDevice
{},
&
StepMountDevice
{},
...
@@ -172,7 +175,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -172,7 +175,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
ForceDeregister
:
b
.
config
.
AMIForceDeregister
,
ForceDeregister
:
b
.
config
.
AMIForceDeregister
,
AMIName
:
b
.
config
.
AMIName
,
AMIName
:
b
.
config
.
AMIName
,
},
},
&
StepRegisterAMI
{},
&
StepRegisterAMI
{
RootVolumeSize
:
b
.
config
.
RootVolumeSize
,
},
&
awscommon
.
StepAMIRegionCopy
{
&
awscommon
.
StepAMIRegionCopy
{
AccessConfig
:
&
b
.
config
.
AccessConfig
,
AccessConfig
:
&
b
.
config
.
AccessConfig
,
Regions
:
b
.
config
.
AMIRegions
,
Regions
:
b
.
config
.
AMIRegions
,
...
...
builder/amazon/chroot/step_create_volume.go
View file @
5d2ea088
...
@@ -4,6 +4,8 @@ import (
...
@@ -4,6 +4,8 @@ import (
"fmt"
"fmt"
"log"
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
awscommon
"github.com/mitchellh/packer/builder/amazon/common"
awscommon
"github.com/mitchellh/packer/builder/amazon/common"
...
@@ -17,6 +19,7 @@ import (
...
@@ -17,6 +19,7 @@ import (
// volume_id string - The ID of the created volume
// volume_id string - The ID of the created volume
type
StepCreateVolume
struct
{
type
StepCreateVolume
struct
{
volumeId
string
volumeId
string
RootVolumeSize
int64
}
}
func
(
s
*
StepCreateVolume
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
s
*
StepCreateVolume
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
...
@@ -43,14 +46,18 @@ func (s *StepCreateVolume) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -43,14 +46,18 @@ func (s *StepCreateVolume) Run(state multistep.StateBag) multistep.StepAction {
}
}
ui
.
Say
(
"Creating the root volume..."
)
ui
.
Say
(
"Creating the root volume..."
)
vs
:=
*
rootDevice
.
EBS
.
VolumeSize
if
s
.
RootVolumeSize
>
*
rootDevice
.
EBS
.
VolumeSize
{
vs
=
s
.
RootVolumeSize
}
createVolume
:=
&
ec2
.
CreateVolumeInput
{
createVolume
:=
&
ec2
.
CreateVolumeInput
{
AvailabilityZone
:
instance
.
Placement
.
AvailabilityZone
,
AvailabilityZone
:
instance
.
Placement
.
AvailabilityZone
,
Size
:
rootDevice
.
EBS
.
VolumeSize
,
Size
:
aws
.
Long
(
vs
)
,
SnapshotID
:
rootDevice
.
EBS
.
SnapshotID
,
SnapshotID
:
rootDevice
.
EBS
.
SnapshotID
,
VolumeType
:
rootDevice
.
EBS
.
VolumeType
,
VolumeType
:
rootDevice
.
EBS
.
VolumeType
,
IOPS
:
rootDevice
.
EBS
.
IOPS
,
IOPS
:
rootDevice
.
EBS
.
IOPS
,
}
}
log
.
Printf
(
"Create args: %
#v"
,
createVolume
)
log
.
Printf
(
"Create args: %
s"
,
awsutil
.
StringValue
(
createVolume
)
)
createVolumeResp
,
err
:=
ec2conn
.
CreateVolume
(
createVolume
)
createVolumeResp
,
err
:=
ec2conn
.
CreateVolume
(
createVolume
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
builder/amazon/chroot/step_register_ami.go
View file @
5d2ea088
...
@@ -11,7 +11,9 @@ import (
...
@@ -11,7 +11,9 @@ import (
)
)
// StepRegisterAMI creates the AMI.
// StepRegisterAMI creates the AMI.
type
StepRegisterAMI
struct
{}
type
StepRegisterAMI
struct
{
RootVolumeSize
int64
}
func
(
s
*
StepRegisterAMI
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
s
*
StepRegisterAMI
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
Config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
Config
)
...
@@ -30,6 +32,10 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -30,6 +32,10 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
}
else
{
}
else
{
newDevice
.
EBS
=
&
ec2
.
EBSBlockDevice
{
SnapshotID
:
aws
.
String
(
snapshotId
)}
newDevice
.
EBS
=
&
ec2
.
EBSBlockDevice
{
SnapshotID
:
aws
.
String
(
snapshotId
)}
}
}
if
s
.
RootVolumeSize
>
*
newDevice
.
EBS
.
VolumeSize
{
newDevice
.
EBS
.
VolumeSize
=
aws
.
Long
(
s
.
RootVolumeSize
)
}
}
}
// assume working from a snapshot, so we unset the Encrypted field if set,
// assume working from a snapshot, so we unset the Encrypted field if set,
...
...
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