Commit Graph

27 Commits

Author SHA1 Message Date
Scott Crunkleton b54b82d3ac Some googlecompute fixes and cleanup. Addresses https://github.com/mitchellh/packer/issues/3829. Changes:
- startup scripts don't run for Windows since it is isn't implemented yet.
- startup scripts use instance metadata instead of serial port output to flag when they are done.
- added licenses to Image data type (to check if an Image is a  Windows Image).
- added GetImage and GetImageFromProject to googlecompute Drivers.
- changed some of the builder/googlecompute tests to use github.com/stretchr/testify/assert.

Tests:
- (in the Packer directory) `go test .`, `go test ./builder/googlecompute`, and `go test ./post-processor/googlecompute-export`
- manual run of `packer build packer_template.json` with the following files

--packer_template.json--
{
  "builders": [
    {
      "type": "googlecompute",
      "account_file": "creds.json",
      "project_id": "google.com:packer-test",
      "source_image": "debian-8-jessie-v20160629",
      "zone": "us-central1-a",
      "startup_script_file": "startup_script.sh",
      "metadata": {
        "startup-script": "#!/bin/sh\necho \"This should be overwritten.\"",
        "startup-script-log-dest": "gs://packer-test.google.com.a.appspot.com/startup-script.log"
      },
      "image_name": "test-packer-modifications",
      "ssh_username": "foo"
    }
  ],
  "post-processors": [
    {
      "type": "googlecompute-export",
      "paths": [
        "gs://packer-test.google.com.a.appspot.com/foo.tar.gz",
        "gs://packer-test.google.com.a.appspot.com/bar.tar.gz"
      ],
      "keep_input_artifact": true
    }
  ]
}

--startup_script.sh--
\#!/bin/sh
echo "Hi, my name is Scott. I'm waiting 60 seconds!" >> /scott
sleep 60
echo "I'm done waiting!" >> /scott
2016-09-09 16:22:50 -07:00
crunk1 55b5a45ae4 Created googlecompute-export post-processor. Modified the googlecompute builder to pass a few configuration values to its resulting artifact. These values can then be used in googlecompute-export post-processor.
Added documentation and changed authentication stuff on temporary VM.
2016-08-15 14:36:26 -07:00
Evan Brown a5c598264f builder/googlecompute: Support provisioning VM without external IP address
This change adds an `omit_external_ip` configuration property that, when true,
will cause no external IP address to be associated with the Google Compute
Engine VM provisioned to create an image. When using `omit_external_ip`, you
must also set the `use_internal_ip` configuration property to true.

Addresses #3296
2016-08-02 13:43:04 -07:00
Scott Crunkleton 7190fbeed8 Adding support for googlecompute startup scripts.
- Startup scripts can be provided through the instance creation metadata field 'startup-script'.
- Script log can be copied to a GCS location by setting the metadata field 'startup-script-log-dest'.
Added Retry method to googlecompute package.
Added GetSerialPortOutput to googlecompute Drivers.
Added StepWaitInstanceStartup (and associated test) which waits for an
instance startup-script to finish.
Changed the instance service account to use the same service account as the one provided in the Packer config template. It was the project default service account.

Tested googlecompute package with 'go test' and also performed builds
with a startup script and without a startup script.
2016-07-20 14:54:36 -07:00
Chris Bednarski 1b1bbb604e Merge branch 'googlecompute-disk-type' of https://github.com/meatballhat/packer into f-google-disk-type 2016-03-10 14:51:30 -08:00
Matt Morrison 942aaa7a85 Add support for Google subnetworks. Closes #3062. Fixes an issue with how packer populates instances metadata. Closes #3181 2016-02-11 17:31:46 +13:00
Caius Howcroft 069c3c21b1 Added support for GCE external static IPs 2015-12-24 19:15:41 -06:00
YAMADA Tsuyoshi afd314959b supported `preemptible` in googlecompute builder 2015-12-05 05:13:35 +09:00
Dan Buch cac93d311c builder/googlecompute: accept disk type, default pd-standard 2015-10-13 20:18:26 -04:00
Mitchell Hashimoto 502076c92e builder/googlecompute: use helper/comm 2015-06-13 18:30:16 -04:00
duftler 6d28ee931c Delete GCE disk on SIGINT. 2015-04-21 18:02:05 +00:00
Dustin Carlino 23c947acf0 Create GCE image from persistent disk instead of from a tarball.
The new flow:
1) Provision the instance
2) Tear down the instance, but keep the boot disk
3) Create an image from the disk
4) Tear down the disk

The step to update gcloud is no longer needed, since gceimagebundle isn't used anymore.
Fixes #1507 and addresses https://github.com/mitchellh/packer/issues/1447#issuecomment-61610235.
2014-11-25 17:07:06 -08:00
Mitchell Hashimoto e422a45449 fmt 2014-10-28 08:35:21 -07:00
Matt Page 0fe61fa1e0 fix: Respect metadata supplied for GCE builders.
Previously, any per instance metadata supplied via the GCE builder
was ignored.

Test plan:

- make test
- Manual testing via:
-- Created a packer config that contained a GCE builder with custom
   metadata set.
-- Ran `packer build`.
-- Verified the instance had the correct metadata in the GCE console.
2014-10-06 14:18:34 -07:00
Mitchell Hashimoto 752162c234 fmt 2014-09-02 09:55:06 -07:00
Matt Page 8f237b7b94 Allow specifying project for source images in GCE
Within GCE, images may be shared across projects. Prior to this
commit, there was no way to inform the GCE builder that a source
image belonged to a specific project. This adds an optional
'source_image_project_id' key to the GCE builder config.
2014-08-20 10:20:28 -07:00
Jessica Frazelle 8bc696ce9e add disk size to google compute, so as to avoid disk size errors on exporting the image 2014-08-08 14:39:03 -04:00
Brett Porter e169013527 builder/googlecompute: configure instance name
Retain the current default of an instance name generated by UUID, but allow
users to choose a specific one. Useful for provisioning with Puppet when a
node name is used to select the right manifest.
2014-04-26 12:17:02 +10:00
Mitchell Hashimoto 5f01415fb7 builder/googlecompute: tests for #867 2014-02-21 15:10:09 -08:00
Prasanna Santhanam d4c9ed43c9 Formatted googlecompute builder as per `make format` 2014-01-31 22:26:09 +05:30
Prasanna Santhanam 0e98b2a269 Fixes #867: save private key when debugging gce builder
Signed-off-by: Prasanna Santhanam <tsp@qubole.com>
2014-01-31 19:13:31 +05:30
Mitchell Hashimoto 57f707dfcc builder/googlecompute: delete instance 2013-12-12 22:34:47 -08:00
Mitchell Hashimoto f72f7a37d1 builder/googlecompute: fix all sorts of zone issues 2013-12-12 22:23:19 -08:00
Mitchell Hashimoto 2bd6f1e2d7 builder/googlecompute: driver and create instance tests 2013-12-12 21:53:05 -08:00
Mitchell Hashimoto ee9ea170af builder/googlecompute: move config out to seperate file 2013-12-12 21:53:04 -08:00
Kelsey Hightower cc1130962b Use the same license as Packer core 2013-12-12 21:53:04 -08:00
Kelsey Hightower 58c73727e5 builder/googlecompute: Add new googlecompute builder 2013-12-12 21:53:03 -08:00