From 6d6d262308873a4ec96f80d606b3d2f6e0f42999 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Fri, 26 Oct 2018 21:56:00 -0700 Subject: [PATCH] some final fixes and documentation work --- builder/oracle/classic/pv_config.go | 18 ++++++------- .../oracle/classic/step_create_pv_builder.go | 2 +- .../docs/builders/oracle-classic.html.md | 26 ++++++++++++------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/builder/oracle/classic/pv_config.go b/builder/oracle/classic/pv_config.go index b22949242..68dd48e61 100644 --- a/builder/oracle/classic/pv_config.go +++ b/builder/oracle/classic/pv_config.go @@ -9,6 +9,7 @@ import ( ) const imageListDefault = "/oracle/public/OL_7.2_UEKR4_x86_64" +const imageListEntryDefault = 5 const usernameDefault = "opc" const shapeDefault = "oc3" const uploadImageCommandDefault = ` @@ -71,16 +72,9 @@ type PVConfig struct { // Builder Image BuilderShape string `mapstructure:"builder_shape"` BuilderImageList string `mapstructure:"builder_image_list"` - BuilderImageListEntry int `mapstructure:"builder_image_list_entry"` + BuilderImageListEntry *int `mapstructure:"builder_image_list_entry"` BuilderComm communicator.Config `mapstructure:"builder_communicator"` - /* TODO: - * Documentation - * split master/builder image/connection config. i.e. build anything, master only linux - possible ignore everything for builder and always use SSH keys - * Need to prepare the ssh config - * Possible also to just have nested config? - */ } // IsPV tells us if we're using a persistent volume for this build @@ -121,8 +115,12 @@ func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) { // 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.BuilderImageListEntry == nil { + var entry int + if c.BuilderImageList == imageListDefault { + entry = imageListEntryDefault + } + c.BuilderImageListEntry = &entry } if c.BuilderUploadImageCommand == "" { diff --git a/builder/oracle/classic/step_create_pv_builder.go b/builder/oracle/classic/step_create_pv_builder.go index 7ca11464a..cfc5e14e8 100644 --- a/builder/oracle/classic/step_create_pv_builder.go +++ b/builder/oracle/classic/step_create_pv_builder.go @@ -47,7 +47,7 @@ func (s *stepCreatePVBuilder) Run(_ context.Context, state multistep.StateBag) m }, ImageList: config.BuilderImageList, SSHKeys: []string{config.Comm.SSHKeyPairName}, - Entry: config.BuilderImageListEntry, + Entry: *config.BuilderImageListEntry, } instanceInfo, err := instanceClient.CreateInstance(input) diff --git a/website/source/docs/builders/oracle-classic.html.md b/website/source/docs/builders/oracle-classic.html.md index 352ad2dd5..93e30161e 100644 --- a/website/source/docs/builders/oracle-classic.html.md +++ b/website/source/docs/builders/oracle-classic.html.md @@ -59,6 +59,9 @@ builder. This builder currently only works with the SSH communicator. CLI, as described [here](https://docs.oracle.com/en/cloud/iaas/compute-iaas-cloud/stopc/image-lists-stclr-and-nmcli.html#GUID-DB7E75FE-F752-4FF7-AB70-3C8DCDFCA0FA) +- `source_image_list_entry` (string) - The entry identifying the machine + image to use in the image list. Defaults to the latest available entry. + - `password` (string) - Your account password. - `shape` (string) - The template that determines the number of CPUs, amount @@ -118,16 +121,20 @@ becomes your machine image. This relies on the disk of the created instance being large enough to perform your entire provisioning process. If that disk size isn't sufficient, we can build with a persistent volume of arbitrary size. -The way it works is that we create a persistent volume of the requested size. -This volume is bootable and initialized with your image list. We start an -instance with this volume as the boot volume. After this instance launches, we -provision and terminate it, leaving the persistent volume around. +First, we create a persistent volume of the requested size. This volume is +bootable and initialized with your image list. We start an instance with this +volume as the boot volume. After this instance launches, we provision and +terminate it, leaving the persistent volume around. Next, we create a second instance, the "builder", this time booting from -instance storage. We also attach a new persistent volume to it, making it twice -the size of the original. We connect to this instance and copy the contents of -the first volume into a tarball file on the second volume. We can upload this -file to Object Storage Classic, and create a new machine image with it. +instance storage. We also attach a new persistent volume, making it twice the +size of the original. We connect to this instance and copy the contents of the +first volume into a tarball file on the second volume. We then upload this file +to Object Storage Classic, and create a new machine image with it. + +For more details, see this [blog +post](https://blogs.oracle.com/cloudmarketplace/creating-an-oracle-compute-machine-image-from-an-instance-with-persistent-boot-storage), +which discusses the strategy used here. If this is set, a few more options become available. @@ -156,7 +163,8 @@ If this is set, a few more options become available. - `builder_image_list_entry` (string) - The entry identifying the machine image to use in the image list. If `builder_image_list` is unset, this defaults to `5`, which is a working image as of this time. Otherwise, it - defaults to 0, which + defaults to the latest entry. Set this to `0` to force it to use the latest + entry when using the default `builder_image_list`. - `builder_shape` (string) - The template that determines the number of CPUs, amount of memory, and other resources allocated to the builder instance.