133 Commits

Author SHA1 Message Date
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
Megan Marsh
f5806afda8 update docs 2019-12-02 16:04:29 -08:00
Megan Marsh
effd330945 make sure we continue to default to Megabytes for qemu disk size to prevent backwards incompatabilities. 2019-12-02 15:13:17 -08:00
Megan Marsh
98c94ab8cb
Merge pull request #7676 from ltrager/master
Add display template option for qemu.
2019-11-07 15:41:17 -08:00
Megan Marsh
d010762dbf Revert "Revert "Qemu builder disk size as a string""
This reverts commit 9c782f4d04e3078691796c075f34489025bf9579.
2019-11-04 14:28:48 -08:00
Adrien Delorme
078ba7c8c3 commit old code generation tool
for history
2019-10-15 12:56:42 +02:00
Megan Marsh
9c782f4d04 Revert "Qemu builder disk size as a string"
This reverts commit 1ecfa032ba0e0e320f279a79394b6118c775dfb7.
2019-10-14 13:09:22 -07:00
Lee Trager
c7f38b232f Add display template option for QEMU. Fixes #7675 2019-10-08 12:04:49 -07:00
Megan Marsh
19a9d7149f fix structs and regenerate partials 2019-10-01 13:36:55 -07:00
Kevin Faulkner
1ecfa032ba Qemu builder disk size as a string 2019-10-01 13:27:02 -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
Adrien Delorme
94bb33db57 fix triple backtick indentation 2019-08-27 13:37:28 +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
Jayson Cofell
7f5fd4851e QEMU: Remove QMPEnable and depend upon VNC password usage for QMP enablement. 2019-07-16 08:56:22 -06:00
Jayson Cofell
5c5943b8ba Add VNC Password support to QEMU builder 2019-07-03 18:38:56 -06:00
Jayson Cofell
afe9ba2869 QEMU: Initial QMP support 2019-07-03 18:33:59 -06:00
Megan Marsh
eb8c74bf85 allow ssh_host config option to override host logic for all builders 2019-07-02 13:56:28 -07:00
Jayson Cofell
e690cb90ce Go fmt AdditionalDiskSizes code 2019-06-24 18:36:01 -06:00
Jayson Cofell
c9b693080a Add additional disk support for QEMU builder. 2019-06-24 17:35:06 -06:00
Adrien Delorme
926c8bbaa6 refactor ShutdownConfig into a single struct 2019-06-14 12:17:28 +02:00
Adrien Delorme
76f50619b1 builder/qemu/builder.go: Document from Config file 2019-06-14 11:52:38 +02:00
Adrien Delorme
4399684372 make fmt autogenerated docs 2019-06-06 16:29:25 +02:00
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
Adrien Delorme
a4bf94dd3c change Builder to be passed a context for cancellation
we have to to give it to our hook
2019-04-03 15:55:55 +02:00
Adrien Delorme
a3838ecfad error on negative ports 2019-03-19 15:21:09 +01:00
Adrien Delorme
5a6dffde9a use port as ints 2019-03-19 15:01:12 +01:00
Adrien Delorme
c214f6735b make everything a uint 2019-03-19 12:54:15 +01:00
Adrien Delorme
446105e384 quemu stepConfigureVNC: use common/net pkg to find open port 2019-03-19 12:54:15 +01:00
Adrien Delorme
9f82b75e57 Use the hashicorp/go-getter to download files
* removed packer.Cache and references since packer.Cache is never used except in the download step. The download step now uses the new func packer.CachePath(targetPath) for this, the behavior is the same.
* removed download code from packer that was reimplemented into the go-getter library: progress bar, http download restart, checksuming from file, skip already downloaded files, symlinking, make a download cancellable by context.
* on windows if packer is running without symlinking rights and we are getting a local file, the file will be copied instead to avoid errors.
* added unit tests for step_download that are now CI tested on windows, mac & linux.
* files are now downloaded under cache dir `sha1(filename + "?checksum=" + checksum) + file_extension`
* since the output dir is based on the source url and the checksum, when the checksum fails, the file is auto deleted.
* a download file is protected and locked by a file lock,
* updated docs
* updated go modules and vendors
2019-03-13 12:11:58 +01:00
Megan Marsh
e4dca0016c
Merge pull request #7156 from vtolstov/qemu
qemu: Add configuration options to specify cpu count and memory size
2019-01-23 15:19:08 -08:00
Vasiliy Tolstov
b6ebe00249 provide memory and cpus like other builders does
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2019-01-23 13:21:52 +03:00
Nelson Chen
b39f398fda Add support for whpx accelerator to qemu builder
Windows Hypervisor Platform (WHPX) is the Windows counterpart to HVF and
KVM. It's an operating system provided component that provides
virtualization acceleration support.

This is kind of the missing counterpart to https://github.com/hashicorp/packer/pull/6193.
QEMU 2.12 also added support for WHPX.

There's no support for libvirt on Windows so nothing was added in those
areas.

The popular QEMU for Windows distribution does not have WHPX support
built-in for legal reasons as the maintainer does not wish to use or
obtain any part of Microsoft's SDK to compile the distribution.
2019-01-03 15:20:37 -08:00
Konstantin Shloma
fe341e2bd0 fix go source formatting
add description to documentation page
2018-10-10 16:16:23 +03:00
Konstantin Shloma
1155347b55 add qemu disk detect-zeroes= option 2018-10-10 14:38:59 +03:00
Megan Marsh
38cc525ec7 new option allowing user to clean up the ephemeral ssh key from the authorized_keys file 2018-09-14 11:06:38 -07:00
Adrien Delorme
41f6e0334d refactor all copy pasted sshConfig with into communicator.Config.SSHConfigFunc
* still need to append the auth methods into an array for gracefullness
2018-08-22 17:02:23 +02:00
Matt Coleman
3192f5e0da qemu builder: add the 'use_backing_file' setting for QCOW2 images 2018-05-16 10:22:50 -04:00
Matthew Hooker
4f1395e0f6
builder/qemu: properly prepare boot command. 2018-05-01 12:40:00 -07:00
Adam Robinson
29b89e63b8 add support for hvf accelerator to qemu builder 2018-04-27 10:11:20 -04:00
Matthew Hooker
024fac4b4f
Merge pull request #6129 from hashicorp/bc_replace
Replace boot command parser with PEG parser.
2018-04-20 12:21:20 -07:00
Evgeni Golov
5a10e5a038
fix invalid disc_discard setting error message 2018-04-20 13:17:40 +02:00
Matthew Hooker
c8e76ce298
implement config struct for qemu 2018-04-19 14:26:31 -07:00
Matthew Hooker
bf0a320125
Implement new parser for qemu boot command 2018-04-19 14:26:29 -07:00
Matthew Hooker
baf8d30ad2
Merge pull request #5738 from testworksau/intel-haxm-support
Add Intel HAXM support to QEMU builder
2018-01-31 12:41:15 -08:00
Matthew Hooker
366dc3da0a
move multistep imports to helper.
gomvpkg -from "github.com/mitchellh/multistep" -to "github.com/hashicorp/packer/helper/multistep"
2018-01-24 17:09:15 -08:00
Glenn McDonald
7250c4f7f0 Add Intel HAXM support to QEMU builder 2017-12-29 11:51:57 +11:00