fix pty, some todo and refactor of bash scri[t
This commit is contained in:
parent
fc301601e1
commit
7a35e2408f
|
@ -71,6 +71,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
|
||||
var steps []multistep.Step
|
||||
if b.config.IsPV() {
|
||||
builderCommConfig := b.config.Comm
|
||||
builderCommConfig.SSHPty = true
|
||||
|
||||
steps = []multistep.Step{
|
||||
&stepCreatePersistentVolume{
|
||||
volumeSize: fmt.Sprintf("%d", b.config.PersistentVolumeSize),
|
||||
|
@ -114,7 +117,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
instanceInfoKey: "builder_instance_info",
|
||||
},
|
||||
&communicator.StepConnect{
|
||||
Config: &b.config.Comm,
|
||||
Config: &builderCommConfig,
|
||||
Host: ocommon.CommHost,
|
||||
SSHConfig: b.config.Comm.SSHConfigFunc(),
|
||||
},
|
||||
|
|
|
@ -34,6 +34,21 @@ func (c *PVConfig) Prepare(ctx *interpolate.Context) (errs *packer.MultiError) {
|
|||
# Split diskimage in to 100mb chunks
|
||||
split -b 100m diskimage.tar.gz segment_
|
||||
|
||||
# Download jq tool
|
||||
curl -OL https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
|
||||
mv jq-linux64 jq
|
||||
chmod u+x jq
|
||||
|
||||
# Create manifest file
|
||||
(
|
||||
for i in segment_*; do
|
||||
./jq -n --arg path "{{.Container}}/$i" \
|
||||
--arg etag $(md5sum $i | cut -f1 -d' ') \
|
||||
--arg size_bytes $(stat --printf "%s" $i) \
|
||||
'{path: $path, etag: $etag, size_bytes: $size_bytes}'
|
||||
done
|
||||
) | ./jq -s . > manifest.json
|
||||
|
||||
# Authenticate
|
||||
curl -D auth-headers -s -X GET \
|
||||
-H "X-Storage-User: Storage-{{.AccountID}}:{{.Username}}" \
|
||||
|
@ -53,21 +68,6 @@ for i in segment_*; do
|
|||
${STORAGE_URL}/{{.Container}}/$i;
|
||||
done
|
||||
|
||||
# Download jq tool
|
||||
curl -OL https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
|
||||
mv jq-linux64 jq
|
||||
chmod u+x jq
|
||||
|
||||
# Create manifest file
|
||||
(
|
||||
for i in segment_*; do
|
||||
./jq -n --arg path "{{.Container}}/$i" \
|
||||
--arg etag $(md5sum $i | cut -f1 -d' ') \
|
||||
--arg size_bytes $(stat --printf "%s" $i) \
|
||||
'{path: $path, etag: $etag, size_bytes: $size_bytes}'
|
||||
done
|
||||
) | ./jq -s . > manifest.json
|
||||
|
||||
# Create machine image from manifest
|
||||
curl -v -X PUT \
|
||||
-H "X-Auth-Token: $AUTH_TOKEN" \
|
||||
|
@ -79,7 +79,6 @@ curl -I -X HEAD \
|
|||
-H "X-Auth-Token: $AUTH_TOKEN" \
|
||||
"${STORAGE_URL}/compute_images/{{.ImageName}}.tar.gz"
|
||||
|
||||
|
||||
# Delete {{.Container}}
|
||||
# following https://docs.oracle.com/en/cloud/iaas/storage-cloud/cssto/deleting-multiple-objects-single-operation.html
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ func (s *stepCreateImage) Run(_ context.Context, state multistep.StateBag) multi
|
|||
|
||||
command := fmt.Sprintf(`#!/bin/sh
|
||||
set -e
|
||||
set -x
|
||||
mkdir /builder
|
||||
mkfs -t ext3 /dev/xvdb
|
||||
mount /dev/xvdb /builder
|
||||
|
@ -90,6 +91,7 @@ func (s *stepCreateImage) Run(_ context.Context, state multistep.StateBag) multi
|
|||
// image_file.tar.gz, where image_file is the .tar.gz name of the machine image file that you have uploaded to Oracle Cloud Infrastructure Object Storage Classic.
|
||||
File: fmt.Sprintf("%s.tar.gz", s.imageName),
|
||||
}
|
||||
log.Printf("CreateMachineImageInput: %+v", createMI)
|
||||
mi, err := machineImageClient.CreateMachineImage(createMI)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error creating machine image: %s", err)
|
||||
|
@ -106,6 +108,7 @@ func (s *stepCreateImage) Run(_ context.Context, state multistep.StateBag) multi
|
|||
5. Configuration (master/builder images & entry, destination stuff, etc)
|
||||
6. split master/builder image/connection config. i.e. build anything, master only linux
|
||||
7. correct artifact
|
||||
8. hide password from logs
|
||||
*/
|
||||
//machineImageClient.CreateMachineImage()
|
||||
|
||||
|
|
Loading…
Reference in New Issue