Adding some missing configuration
This commit is contained in:
parent
c42be62d90
commit
6f729d0265
|
@ -76,17 +76,18 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
|
|
||||||
steps = []multistep.Step{
|
steps = []multistep.Step{
|
||||||
&stepCreatePersistentVolume{
|
&stepCreatePersistentVolume{
|
||||||
volumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize),
|
VolumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize),
|
||||||
volumeName: fmt.Sprintf("master-storage_%s", runID),
|
VolumeName: fmt.Sprintf("master-storage_%s", runID),
|
||||||
sourceImageList: b.config.SourceImageList,
|
ImageList: b.config.SourceImageList,
|
||||||
bootable: true,
|
ImageListEntry: b.config.SourceImageListEntry,
|
||||||
|
Bootable: true,
|
||||||
},
|
},
|
||||||
&stepCreatePersistentVolume{
|
&stepCreatePersistentVolume{
|
||||||
// We multiple the master volume size by 2, because we need
|
// We double the master volume size because we need room to
|
||||||
// room to tarball the disk image. We also need to chunk the
|
// tarball the disk image. We also need to chunk the tar ball,
|
||||||
// tar ball, but we can remove the original disk image first.
|
// but we can remove the original disk image first.
|
||||||
volumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize*2),
|
VolumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize*2),
|
||||||
volumeName: fmt.Sprintf("builder-storage_%s", runID),
|
VolumeName: fmt.Sprintf("builder-storage_%s", runID),
|
||||||
},
|
},
|
||||||
&ocommon.StepKeyPair{
|
&ocommon.StepKeyPair{
|
||||||
Debug: b.config.PackerDebug,
|
Debug: b.config.PackerDebug,
|
||||||
|
|
|
@ -33,6 +33,7 @@ type Config struct {
|
||||||
ImageName string `mapstructure:"image_name"`
|
ImageName string `mapstructure:"image_name"`
|
||||||
Shape string `mapstructure:"shape"`
|
Shape string `mapstructure:"shape"`
|
||||||
SourceImageList string `mapstructure:"source_image_list"`
|
SourceImageList string `mapstructure:"source_image_list"`
|
||||||
|
SourceImageListEntry int `mapstructure:"source_image_list_entry"`
|
||||||
SnapshotTimeout time.Duration `mapstructure:"snapshot_timeout"`
|
SnapshotTimeout time.Duration `mapstructure:"snapshot_timeout"`
|
||||||
DestImageList string `mapstructure:"dest_image_list"`
|
DestImageList string `mapstructure:"dest_image_list"`
|
||||||
// Attributes and Attributes file are both optional and mutually exclusive.
|
// Attributes and Attributes file are both optional and mutually exclusive.
|
||||||
|
|
|
@ -1,18 +1,24 @@
|
||||||
package classic
|
package classic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const imageListDefault = "/oracle/public/OL_7.2_UEKR4_x86_64"
|
||||||
|
|
||||||
type PVConfig struct {
|
type PVConfig struct {
|
||||||
// PersistentVolumeSize lets us control the volume size by using persistent boot storage
|
// PersistentVolumeSize lets us control the volume size by using persistent boot storage
|
||||||
PersistentVolumeSize int `mapstructure:"persistent_volume_size"`
|
PersistentVolumeSize int `mapstructure:"persistent_volume_size"`
|
||||||
BuilderImageList string `mapstructure:"builder_image_list"`
|
|
||||||
BuilderUploadImageCommand string `mapstructure:"builder_upload_image_command"`
|
BuilderUploadImageCommand string `mapstructure:"builder_upload_image_command"`
|
||||||
|
|
||||||
|
// Builder Image
|
||||||
|
BuilderShape string `mapstructure:"builder_shape"`
|
||||||
|
BuilderImageList string `mapstructure:"builder_image_list"`
|
||||||
|
BuilderImageListEntry int `mapstructure:"builder_image_list_entry"`
|
||||||
/* TODO:
|
/* TODO:
|
||||||
default to OL image
|
|
||||||
make sure if set then PVS is above
|
|
||||||
some way to choose which connection to use for master
|
some way to choose which connection to use for master
|
||||||
possible ignore everything for builder and always use SSH keys
|
possible ignore everything for builder and always use SSH keys
|
||||||
*/
|
*/
|
||||||
|
@ -25,7 +31,29 @@ func (c *PVConfig) IsPV() bool {
|
||||||
|
|
||||||
func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) {
|
func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) {
|
||||||
if !c.IsPV() {
|
if !c.IsPV() {
|
||||||
return nil
|
if c.BuilderShape != "" {
|
||||||
|
errs = packer.MultiErrorAppend(errs,
|
||||||
|
fmt.Errorf("`builder_shape` has no meaning when `persistent_volume_size` is not set."))
|
||||||
|
}
|
||||||
|
if c.BuilderImageList != "" {
|
||||||
|
errs = packer.MultiErrorAppend(errs,
|
||||||
|
fmt.Errorf("`builder_shape_image_list` has no meaning when `persistent_volume_size` is not set."))
|
||||||
|
}
|
||||||
|
return errs
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.BuilderShape == "" {
|
||||||
|
c.BuilderShape = "oc3"
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.BuilderImageList == "" {
|
||||||
|
c.BuilderImageList = imageListDefault
|
||||||
|
}
|
||||||
|
|
||||||
|
// Entry 5 is a working default, so let's set it if the entry is unset and
|
||||||
|
// we're using the default image list
|
||||||
|
if c.BuilderImageList == imageListDefault && c.BuilderImageListEntry == 0 {
|
||||||
|
c.BuilderImageListEntry = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.BuilderUploadImageCommand == "" {
|
if c.BuilderUploadImageCommand == "" {
|
||||||
|
|
|
@ -34,6 +34,7 @@ func (s *stepCreateInstance) Run(_ context.Context, state multistep.StateBag) mu
|
||||||
Name: config.ImageName,
|
Name: config.ImageName,
|
||||||
Shape: config.Shape,
|
Shape: config.Shape,
|
||||||
ImageList: config.SourceImageList,
|
ImageList: config.SourceImageList,
|
||||||
|
Entry: config.SourceImageListEntry,
|
||||||
Networking: map[string]compute.NetworkingInfo{"eth0": netInfo},
|
Networking: map[string]compute.NetworkingInfo{"eth0": netInfo},
|
||||||
Attributes: config.attribs,
|
Attributes: config.attribs,
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type stepCreatePersistentVolume struct {
|
type stepCreatePersistentVolume struct {
|
||||||
volumeSize string
|
VolumeSize string
|
||||||
volumeName string
|
VolumeName string
|
||||||
bootable bool
|
Bootable bool
|
||||||
sourceImageList string
|
ImageList string
|
||||||
|
ImageListEntry int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stepCreatePersistentVolume) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
func (s *stepCreatePersistentVolume) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||||
|
@ -23,11 +24,12 @@ func (s *stepCreatePersistentVolume) Run(_ context.Context, state multistep.Stat
|
||||||
ui.Say("Creating Volume...")
|
ui.Say("Creating Volume...")
|
||||||
|
|
||||||
c := &compute.CreateStorageVolumeInput{
|
c := &compute.CreateStorageVolumeInput{
|
||||||
Name: s.volumeName,
|
Name: s.VolumeName,
|
||||||
Size: s.volumeSize,
|
Size: s.VolumeSize,
|
||||||
ImageList: s.sourceImageList,
|
ImageList: s.ImageList,
|
||||||
|
ImageListEntry: s.ImageListEntry,
|
||||||
Properties: []string{"/oracle/public/storage/default"},
|
Properties: []string{"/oracle/public/storage/default"},
|
||||||
Bootable: s.bootable,
|
Bootable: s.Bootable,
|
||||||
}
|
}
|
||||||
|
|
||||||
sc := client.StorageVolumes()
|
sc := client.StorageVolumes()
|
||||||
|
@ -59,7 +61,7 @@ func (s *stepCreatePersistentVolume) Cleanup(state multistep.StateBag) {
|
||||||
ui.Say("Cleaning up Volume...")
|
ui.Say("Cleaning up Volume...")
|
||||||
|
|
||||||
c := &compute.DeleteStorageVolumeInput{
|
c := &compute.DeleteStorageVolumeInput{
|
||||||
Name: s.volumeName,
|
Name: s.VolumeName,
|
||||||
}
|
}
|
||||||
|
|
||||||
sc := client.StorageVolumes()
|
sc := client.StorageVolumes()
|
||||||
|
@ -69,5 +71,5 @@ func (s *stepCreatePersistentVolume) Cleanup(state multistep.StateBag) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.Message(fmt.Sprintf("Deleted volume: %s", s.volumeName))
|
ui.Message(fmt.Sprintf("Deleted volume: %s", s.VolumeName))
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ func (s *stepCreatePVBuilder) Run(_ context.Context, state multistep.StateBag) m
|
||||||
// Instances Input
|
// Instances Input
|
||||||
input := &compute.CreateInstanceInput{
|
input := &compute.CreateInstanceInput{
|
||||||
Name: s.Name,
|
Name: s.Name,
|
||||||
Shape: config.Shape,
|
Shape: config.BuilderShape,
|
||||||
Networking: map[string]compute.NetworkingInfo{
|
Networking: map[string]compute.NetworkingInfo{
|
||||||
"eth0": compute.NetworkingInfo{
|
"eth0": compute.NetworkingInfo{
|
||||||
Nat: []string{ipAddName},
|
Nat: []string{ipAddName},
|
||||||
|
@ -44,10 +44,9 @@ func (s *stepCreatePVBuilder) Run(_ context.Context, state multistep.StateBag) m
|
||||||
Index: 1,
|
Index: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ImageList: config.SourceImageList,
|
ImageList: config.BuilderImageList,
|
||||||
Attributes: config.attribs,
|
|
||||||
SSHKeys: []string{config.Comm.SSHKeyPairName},
|
SSHKeys: []string{config.Comm.SSHKeyPairName},
|
||||||
Entry: 5,
|
Entry: config.BuilderImageListEntry,
|
||||||
}
|
}
|
||||||
|
|
||||||
instanceInfo, err := instanceClient.CreateInstance(input)
|
instanceInfo, err := instanceClient.CreateInstance(input)
|
||||||
|
|
Loading…
Reference in New Issue