Commit Graph

41 Commits

Author SHA1 Message Date
Megan Marsh 81e043f2b0 fix windows tests 2020-05-08 10:13:43 -07:00
Megan Marsh 54b33ad8d1 fix tests 2020-05-08 10:13:43 -07:00
Megan Marsh 32752d4577 fix linting and tests 2020-05-08 10:13:43 -07:00
Megan Marsh b5744efb42 add config prepare tests 2020-05-08 10:13:43 -07:00
Adrien Delorme 0785c2f6fc
build using HCL2 (#8423)
This follows #8232 which added the code to generate the code required to parse
HCL files for each packer component.

All old config files of packer will keep on working the same. Packer takes one
argument. When a directory is passed, all files in the folder with a name
ending with  “.pkr.hcl” or “.pkr.json” will be parsed using the HCL2 format.
When a file ending with “.pkr.hcl” or “.pkr.json” is passed it will be parsed
using the HCL2 format. For every other case; the old packer style will be used.

## 1. the hcl2template pkg can create a packer.Build from a set of HCL (v2) files

I had to make the packer.coreBuild (which is our one and only packer.Build ) a public struct with public fields

## 2. Components interfaces get a new ConfigSpec Method to read a file from an HCL file.

  This is a breaking change for packer plugins.

a packer component can be a: builder/provisioner/post-processor

each component interface now gets a `ConfigSpec() hcldec.ObjectSpec`
which allows packer to tell what is the layout of the hcl2 config meant
to configure that specific component.

This ObjectSpec is sent through the wire (RPC) and a cty.Value is now
sent through the already existing configuration entrypoints:

 Provisioner.Prepare(raws ...interface{}) error
 Builder.Prepare(raws ...interface{}) ([]string, error)
 PostProcessor.Configure(raws ...interface{}) error

close #1768


Example hcl files:

```hcl
// file amazon-ebs-kms-key/run.pkr.hcl
build {
    sources = [
        "source.amazon-ebs.first",
    ]

    provisioner "shell" {
        inline = [
            "sleep 5"
        ]
    }

    post-processor "shell-local" {
        inline = [
            "sleep 5"
        ]
    }
}

// amazon-ebs-kms-key/source.pkr.hcl

source "amazon-ebs" "first" {

    ami_name = "hcl2-test"
    region = "us-east-1"
    instance_type = "t2.micro"

    kms_key_id = "c729958f-c6ba-44cd-ab39-35ab68ce0a6c"
    encrypt_boot = true
    source_ami_filter {
        filters {
          virtualization-type = "hvm"
          name =  "amzn-ami-hvm-????.??.?.????????-x86_64-gp2"
          root-device-type = "ebs"
        }
        most_recent = true
        owners = ["amazon"]
    }
    launch_block_device_mappings {
        device_name = "/dev/xvda"
        volume_size = 20
        volume_type = "gp2"
        delete_on_termination = "true"
    }
    launch_block_device_mappings {
        device_name = "/dev/xvdf"
        volume_size = 500
        volume_type = "gp2"
        delete_on_termination = true
        encrypted = true
    }

    ami_regions = ["eu-central-1"]
    run_tags {
        Name = "packer-solr-something"
        stack-name = "DevOps Tools"
    }
    
    communicator = "ssh"
    ssh_pty = true
    ssh_username = "ec2-user"
    associate_public_ip_address = true
}
```
2019-12-17 11:25:56 +01:00
Miles Crabill 2bff60bac8
address review feedback 2019-09-16 13:50:43 -07:00
Miles Crabill 328baced05
add some test cases for image names 2019-09-16 10:18:22 -07:00
Megan Marsh 617fd18255 supply complete dummy data for googlecompute tests 2019-07-03 15:58:08 -07:00
Pratyush singhal 4a369b4ef1 chore: add test for MetadataFiles option
Signed-off-by: Pratyush singhal <psinghal20@gmail.com>
2019-06-11 17:45:30 +05:30
krisko e96bda6466
Remove config interface. Make CreateImage function to accept config as list of config fields 2019-05-05 17:17:08 +02:00
krisko f1e9664012
Googlebuilder: Add image key encryption 2019-05-02 17:37:43 +02:00
krisko 9b39e3f928
GCP builder add image encryption support 2019-05-02 17:37:36 +02:00
Matthew Aynalem 28eff7303e builder/googlecompute: validate startup_script_file exists 2018-10-15 16:09:33 -07:00
DanHam 5642f8cb01
Remove tmp files created by builder/googlecompute tests 2018-04-30 20:38:03 +01:00
Evan Brown 7eda44d28c builder/googlecompute: disambiguate disable_default_service_account
This change requires 'disable_default_service_account=false' in order to
set 'service_account_email'.

This is a guard against an incorrect assumption
that disabling the default service account would mean that no service
account would be used.
2018-03-13 12:39:41 -07:00
Evan Brown 4a2c124ea2 builder/googlecompute: Optionally disable service account
The ability to use a service account other than the default was
introduced in #5928. This change adds to that by introducing the
'disable_default_service_account' config option. If true - and
'service_account_email' is not set - Packer will create a GCE VM
with no service account.
2018-03-07 20:53:26 -08:00
Petr Hosek eaef2961cb Support specifying licenses for Google Compute images
This is needed to enable features such as the nested virtualization:
https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances
2018-02-03 14:15:16 -06:00
Peter Mounce 15a456750b CI as compiler! 2017-09-19 11:34:08 +01:00
Peter Mounce 2239d55fdb Add test coverage 2017-09-19 11:31:05 +01:00
Saulius Grusnys b6783a1180 Adding sanity checks in Prepare when adding accelerators and tests for accelerator configuration 2017-07-19 11:28:49 +01:00
Dimitri Rudnev 2009fcd9df OnHostMaintenance, googlecompute updating documenation , additional option for validation and setting defaults 2017-02-10 11:57:15 -08:00
Dimitri Rudnev bab590c177 Adding OnHostMaintenance option for googlecompue builder 2017-02-10 10:58:57 -08:00
Rickard von Essen 6947a74151 Merge pull request #4162 from classmarkets/google-source-image-family
builder/googlecompute: support source image family
2016-11-26 17:26:47 +01:00
Rickard von Essen 96e9a8e6e9 Removed default value for ssh_username 2016-11-17 22:30:34 +01:00
Peter Schultz bcb319640e builder/googlecompute: support source image family
Closes #4100
2016-11-13 16:54:04 +01:00
YAMADA Tsuyoshi da7d317e46 googlecompute: Run instance with custom scopes 2016-10-22 15:46:14 +09:00
Peter Schultz a99a417db9 builder/googlecompute: validate image_family 2016-05-13 15:24:02 -07:00
Peter Schultz 8546aafec5 builder/googlecompute: support image family 2016-05-13 15:24:02 -07:00
Matt Morrison daf57c7632 Add tests and documentation for subnetwork attribute 2016-02-11 21:54:48 +13:00
Ryan Uber 7732cf45a0 builder/googlecompute: fix image name defaults 2016-01-19 11:12:19 -08:00
YAMADA Tsuyoshi 18d79cfb3d added test 2015-12-05 15:48:07 +09:00
Chris Bednarski bd6c31c2d9 Added TestImageName and moved private methods to the bottom of the file 2015-07-07 16:18:31 -06:00
Mitchell Hashimoto 6c7a7b6068 builder/googlecompute: default SSH settings properly [GH-2340] 2015-06-29 09:56:33 -07:00
Andrew Bayer ebdd0d991a Adds support for using the internal IP rather than NAT IP in GCE 2015-05-29 14:50:11 -07:00
Dustin Carlino fe47f45800 Remove bucket_name from GCE config.
Fixes #1732. Forgot to do this in 23c947acf0.
2014-12-09 08:44:01 -08: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
Evan Brown ff149df30f Use golang/oauth2, no longer require client_secrets.json, and use
Service Account when run from a GCE Instance.
2014-11-21 12:45:27 -08:00
Mitchell Hashimoto b9f82ef17e fmt 2014-09-05 10:23:49 -07:00
Mitchell Hashimoto b5c0c63ebc builder/googlecompute: use new auth scheme 2014-09-05 09:47:20 -07:00
Mitchell Hashimoto 3657f33a4d builder/googlecompute: StepCreateSSHKey tests 2013-12-12 21:53:05 -08:00
Mitchell Hashimoto fbc07942f0 builder/googlecompute: test config basics 2013-12-12 21:53:04 -08:00