Commit Graph

95 Commits

Author SHA1 Message Date
Megan Marsh 02590f6c44
Merge pull request #9329 from hashicorp/je.website-maintenance-5-29-20
🌷 Website Spring Maintenance
2020-06-03 16:25:23 -07:00
Jeff Escalante f4d7b5f493
fix some stuff 2020-06-02 17:22:40 -04:00
Wei Cheng e0cfb404fb
builder/googlecompute: add support to specify storage location for GCP images (#9326)
* feat: add support to specify storage location for GCP images

Signed-off-by: Wei Cheng <calvinpohwc@gmail.com>
2020-06-02 13:42:33 -04:00
Megan Marsh 9476aa03de
Merge pull request #9105 from hashicorp/google_iap
Implement iap proxy for googlecompute
2020-05-08 12:40:42 -07:00
Megan Marsh c578afc62c working on windows 2020-05-08 10:13:43 -07:00
Megan Marsh 3e1ddad0c7 fix behavior when not using IAP, try to use more sophisticated streaming than buffer.String() 2020-05-08 10:13:42 -07:00
Megan Marsh f67a8ab431 revert unneeded changes to driver roles 2020-05-08 10:13:42 -07:00
Megan Marsh e6073bcec7 implement iap proxy for googlecompute. ssh-only so far 2020-05-08 10:13:42 -07:00
Markus Liljedahl d807e81adb
Changed default disk size for when using googlecompute to match minimum disk sice to the google api. Closes https://github.com/hashicorp/packer/issues/9023 (#9071) 2020-05-08 15:55:38 +02:00
Svetlin Zamfirov b706f02408 Fixing auto-generated code errors 2020-04-16 16:22:42 -07:00
Svetlin Zamfirov d827f4f757 Adding custom shielded images support (GCP)
Adds `enable_secure_boot`, `enable_vtpm` and `enable_integrity_monitoring`
config options to enable building of custom Shielded GCP Compute images.

Feedback on this is more than welcome as this is my first attempt in
contributing to anything Packer related.

Packer is great for us to build custom images on top of GCP but we would
like to enhance that to support Shielded VM images. This will allow us
to have more secure and trusted images which our team(s) will be using.
2020-04-16 16:22:41 -07:00
Jeff Escalante 4afd107eeb
patch source files for extensions changes 2020-04-07 17:50:51 -04:00
Jeff Escalante bcc848a83d
were rendering yay 2020-04-07 17:50:47 -04:00
Megan Marsh 0f9415297f
Merge pull request #8679 from kwibus/gcp-fallback-image
[WIP] fix #8589 gcp public fallback image
2020-04-02 16:49:50 -07:00
Wilken Rivera 7b705545d9
docs: Various doc clean-ups to fix code block formatting and syntax highlighting (#8868) 2020-03-12 15:05:08 +01:00
Rens Sikma 3d8bda31a4 modify docstring 2020-02-20 12:54:35 +01:00
Rens Sikma c8062cc8b3 fix #8679 with source_image_project_id as list 2020-02-06 10:30:04 +01: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
Adrien Delorme 819329228a Change back to make sure all durations are a time.Duration
It is simply the best/simplest solution and trying to prevent users from passing and integer here would be like opening a can of worms. Because:

* we cannot make mapstructure validate our duration string ( with an UnmarshalJSON func etc.)
* we cannot make mapstructure spit a string instead of a duration and packer will decode-encode-decode config.
* the hcl2 generated code asks for a string, so this will be enforced by default.
2019-10-31 16:12:07 +01:00
Adrien Delorme bf3d9841c6 Force durations to be passed a strings
Before this commit it was possible to set a duration using an integer or a float. Go's time.Duration is an int64 internally an mapstructure will take advantage of this and load the number as a int64 but `1` means one ns which is unexpected/confusing. To avoid confusion and enforce readability this forces users to pass a string with a unit for a duration; ex "56s".
2019-10-31 11:47:19 +01:00
Adrien Delorme 078ba7c8c3 commit old code generation tool
for history
2019-10-15 12:56:42 +02:00
Adrien Delorme 17c069baa5 builder.google:
* make CustomerEncryptionKey our own type so that it can be hcl2 generated
* make Account setting unexported so that it doesn't temper with HCL2 generation ( the field is set a bit later after processing )
2019-10-15 12:56:41 +02:00
Megan Marsh 3c14c50aba Allow user to real oauth token from properly configured Vault instance 2019-09-23 13:26:03 -07:00
Adrien Delorme 3fe9d52e3f Merge remote-tracking branch 'origin/master' into scrape_doc_to_builder_struct_config 2019-09-20 11:15:44 +02:00
Miles Crabill 2bff60bac8
address review feedback 2019-09-16 13:50:43 -07:00
Miles Crabill c11a444f77
googlecompute: fail fast when image name is invalid, replace unusable characters w/ -'s 2019-09-16 10:10:41 -07:00
Adrien Delorme 4cb7c30987 Merge remote-tracking branch 'origin/master' into scrape_doc_to_builder_struct_config 2019-08-21 16:44:23 +02:00
Megan Marsh 0dfb3cc56f replace some bespoke google auth code with code from golang's oauth2 library 2019-07-03 14:27:33 -07:00
Adrien Delorme a3e3c313a9 docs: use partials in googlecompute after master merge 2019-06-12 15:18:39 +02:00
Adrien Delorme 6e3dc1aa9a Merge remote-tracking branch 'origin/master' into scrape_doc_to_builder_struct_config 2019-06-12 14:28:11 +02:00
Adrien Delorme 4399684372 make fmt autogenerated docs 2019-06-06 16:29:25 +02:00
Pratyush singhal 1e1af35341 refactor: replace userdata_files with generic metadata_files map
Signed-off-by: Pratyush singhal <psinghal20@gmail.com>
2019-06-06 16:14:57 +05:30
Pratyush singhal 3845186c4c feat: add feature to import user-data from a file
Signed-off-by: Pratyush singhal <psinghal20@gmail.com>
2019-06-06 11:28:59 +05:30
Adrien Delorme e6cbb013ba add // go:generate struct-markdown to all previously edited files 2019-06-05 16:42:18 +02:00
Adrien Delorme f1917edd34 generate the comments for config struct of builders scraping doc website 2019-06-05 16:42:17 +02:00
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 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
Adrien Delorme e37f126cf1 update gcp google.golang.org/api/compute/v1/ 2018-08-21 10:09:01 +02: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
Christophe Courtaut 4befdce47e builder/googlecompute: Adds ability to specify service account
This commit allows user to specify the service account they want
to associate with the virtual machine provisionned by setting
the service_account_email field in the config.

It allows to manage permissions of the instantiated VM properly,
using a service account that can be tied up to IAM roles and
permissions.
2018-02-22 17:19:13 +01: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
Evan Brown bada7b73c1 builder/googlecompute: Selectively set default network
If a network is not specified, it should only be set to "default" if a
subnetwork is also not specified.
2017-11-06 16:41:42 -08:00
Evan Brown 1b3eb1c34d builder/googlecompute: Set default network_project_id
If network_project_id is not specified in the GCE builder config, it
should default to the project_id.
2017-11-06 16:41:42 -08:00
Atsushi Ishibashi 210dd08326 Change args of NewConfig 2017-10-17 13:48:15 +09:00
Atsushi Ishibashi 5310d5629b Modify clean_image_name not defined error 2017-10-17 12:31:50 +09:00
Peter Mounce ac8eedf171 Introduce a new configuration parameter instead
... so that one can have a different list compared to instances.
2017-09-18 17:53:40 +01:00
Patrick Decat a7283f2281 Add support for setting labels on GCE instance 2017-09-06 10:58:08 +02: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