565 Commits

Author SHA1 Message Date
Moss
9216f43463 Configure NAT interface before forwarded port mapping 2019-12-19 17:03:31 +01:00
Moss
42cf9ef064 Remove pointer fixing panic on interface conversion 2019-12-19 13:30:54 +01:00
Adrien Delorme
4b7132c87c Merge remote-tracking branch 'origin/master' into sharing_info 2019-12-17 11:57:09 +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
Megan Marsh
0f6d1beccf add an extra string array to the Prepare() return values in the builder interfaces; this sets up the ability for builders to give the provisioners custom user-accessible build-time variables. 2019-12-16 21:23:05 -08:00
Sylvia Moss
c57f093efe
Remove unnecessary source_path validation for virtualbox-ovf (#8489) 2019-12-16 16:50:21 +01:00
Sylvia Moss
0a8b172bf9 Remove duplicated retry mechanism when deleting VM ffrom virtual box (#8485)
This retry was also added to fix a locked by session error reported in #5501 and fixed in #5512.
2019-12-16 14:31:15 +01:00
Megan Marsh
84063d2132 implement ID and Type values in the provisioner template info sharing 2019-12-13 11:57:01 -08:00
Sylvia Moss
2ee3311082
Retry command execution when VM session is locked (#8483) 2019-12-13 10:47:19 +01:00
Sylvia Moss
c6b9efb522 Fix virtualbox-iso TestBuilderAcc_basic (#8481)
make sure the test works for later usage
2019-12-12 10:43:51 +01:00
Sylvia Moss
2f63c581a0
Remove unnecessary 1 sec sleep (#8453) 2019-12-06 11:43:28 +01:00
Sylvia Moss
5ff5623433
Add disable_shutdown option to VirtualBox builder (#8449) 2019-12-05 14:34:56 +01:00
Adrien Delorme
a36b94320a virtualbox: simplify ParseSnapshotData 2019-11-06 10:24:20 +01:00
Adrien Delorme
116a038de9 Update snapshot.go
avoid a panic on a too short slice.
2019-11-05 15:48:32 +01:00
Adrien Delorme
14243ce56a
Merge pull request #8305 from hashicorp/fix_8301
allow nvme, since virtualbox 6.0 allows it
2019-11-04 17:58:18 +01:00
Adrien Delorme
a23801d4a9 builder.virtualbox.iso: document that EFI mode needs to be enabled for pcie/nvme to work too 2019-11-04 14:30:59 +01:00
Megan Marsh
974eba443a update docs to include warning about extension pack 2019-11-01 09:48:35 -07:00
Adrien Delorme
b790776096 vbox iso: use NVMe Controller when the hard drive interface if pcie 2019-11-01 14:43:59 +01:00
Megan Marsh
6f54468dd5 fix mocks 2019-10-31 15:36:22 -07:00
Megan Marsh
65ad3105b3 udpdate generated code 2019-10-31 15:28:36 -07:00
Megan Marsh
9343a23021 add driver calls to enable nvme controller 2019-10-31 15:21:52 -07:00
Megan Marsh
d2867c47f0 allow nvme, since virtualbox 6.0 allows it 2019-10-31 14:43:46 -07: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
Lars Lehtonen
4a3a011310
builder/virtualbox/vm: fix dropped error 2019-10-01 15:54:28 -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
allinwait
171c2a9a07 add the floppy label option 2019-09-12 12:25:22 +00:00
Brian Fox
5b6dcb0c94 fix(virtualbox) LoadSnapshots should succeed even if VM has no snapshots 2019-09-12 10:51:12 +02:00
Adrien Delorme
597a3e323b Merge remote-tracking branch 'origin/master' into scrape_doc_to_builder_struct_config 2019-09-10 13:20:07 +02:00
Adrien Delorme
350aa54274 Update step_shutdown_test.go
bump test duration
2019-09-10 13:07:30 +02: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
Thomas Meckel
01edafb49f Cleaned up golint warnings 2019-08-19 21:36:43 +02:00
Thomas Meckel
92501cd344 target_snapshot is not optional as described in the documentation 2019-08-19 21:36:43 +02:00
Megan Marsh
06bef2844b
Merge pull request #7996 from hashicorp/fix_7925
dont bother with a targetpath for the vbox additions; use a hash like…
2019-08-19 09:45:38 -07:00
Brian Fox
47c027e5c8 Remove check/requirement for target_snapshot 2019-08-19 11:25:17 +02:00
Megan Marsh
02399f32f6 dont bother with a targetpath for the vbox additions; use a hash like everything else 2019-08-15 15:10:25 -07:00
Thomas Meckel
822b72bd14 Added force_delete_snapshot configuration item and the corresponding checks 2019-07-26 12:34:28 +02:00
Thomas Meckel
e7583de847 StepCreateSnapshot.Run() will stop and create an error if the virtual machine is still running
Removed left over code from StepCreateSnapshot.Cleanup()
2019-07-26 12:34:27 +02:00
Thomas Meckel
d9b8623f64 StepShutdown now always waits for the shutdown of the virtual machine to complete, not only if a shutdown command is specified 2019-07-26 12:34:27 +02:00
Thomas Meckel
b873876670 Added test TestSnapshot_EnsureParents
No using asserts NotNil and Nil
2019-07-26 12:34:27 +02:00
Thomas Meckel
6fd0b3e83e Fixed a bug in ParseSnapshotData
Added fuction GetSnapshots
2019-07-26 12:34:26 +02:00
Thomas Meckel
225a140055 Applied correct source format (got fmt) to builder\virtualbox\common\driver_mock.go 2019-07-26 12:34:26 +02:00
Thomas Meckel
51e5ae69db Corrected method signatures in builder\virtualbox\common\driver_mock.go 2019-07-26 12:34:26 +02:00
Thomas Meckel
ab6a163ff2 Added missing newline at end of builder\virtualbox\common\driver_mock.go 2019-07-26 12:34:25 +02:00
Thomas Meckel
e9b5332e99 Added missing functions to builder\virtualbox\common\driver_mock.go 2019-07-26 12:34:25 +02:00
Thomas Meckel
fd5a2db58f Removed commented (obsolete) code from builder\virtualbox\common\driver_4_2.go 2019-07-26 12:34:25 +02:00
Thomas Meckel
7d3c84e5f9 Changed VirtualBox VM builder according to current builder interface 2019-07-26 12:29:48 +02:00
Thomas Meckel
2ef911f6f0 Fixed bugs in snapshot and builder code 2019-07-26 12:29:47 +02:00
Thomas Meckel
ebd2780e5d implemented first unit tests for snapshot.go 2019-07-26 12:29:46 +02:00