Commit Graph

264 Commits

Author SHA1 Message Date
Sylvia Moss b0c7fe491c
Remove net_device prepare validation (#8979) 2020-04-02 11:34:05 +02:00
Megan Marsh 6008f911fd
Merge pull request #8847 from takaishi/support-keyboard-interactive
communicator/ssh: support keyboard-interactive auth to connect bastion
2020-03-13 11:48:12 -07:00
r_takaishi f50ff1d270 make generate 2020-03-13 11:29:42 +09: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
Wilken Rivera 66ad6f3483
builders: Fix gosimple S1007 linting issue (#8871)
Results before change
```
⇶  golangci-lint run ./... --disable-all --enable=gosimple | grep 1007
builder/alicloud/ecs/image_config.go:208:9: S1007: should use raw string
post-processor/vsphere-template/step_mark_as_template.go:130:8: S1007: shape twice (gosimple)
builder/azure/arm/config.go:58:27: S1007: should use raw string (`...`)
builder/azure/arm/config.go:59:27: S1007: should use raw string (`...`)
builder/qemu/driver.go:192:15: S1007: should use raw string (`...`)
```

Results after change
```
⇶  golangci-lint run ./... --disable-all --enable=gosimple | grep 1007
```
2020-03-11 10:29:22 +01:00
Wilken Rivera e1a46ec293
Fix gosimple S1025 linting errors (#8838)
Remove unneeded use of fmt.Sprintf for variables that are already strings.
2020-03-04 15:31:30 -05:00
Megan Marsh dde74232f2
Clearly document all template-engine-enabled options (#8770) 2020-02-20 11:05:27 +01:00
Wilken Rivera 9ec8b67392
Add golangci-lint to project (#8686)
* Add golangci-lint as linting tool

* Disable failing staticchecks to start; GitHub issue to handle coming soon

* Run `goimports -w` to repair all source files that have improperly
formatted imports

* makefile: Add ci-lint target to run on travis

This change adds a new make target for running golangci-lint on newly
added Go files only. This target is expected to run during Packer ci builds.

* .github/contributing: Add code linting instructions

* travis: Update job configuration to run parallel builds
2020-02-14 11:42:29 -05:00
Sylvia Moss 08b0bd1d2c
Fix HCL2 code generation for slices within another slice (#8669) 2020-02-03 17:03:28 +01:00
Megan Marsh d252a24b82 allow user to set winrm_host override like we do ssh_host override 2020-01-30 15:22:22 -08:00
Sylvia Moss dc31bad539
Sharing info with post-processors via artifact (#8632) 2020-01-30 11:27:58 +01:00
nywilken d2a9e6b32e Format code with `gofmt -s -w` 2020-01-28 16:52:50 -05:00
Megan Marsh e57004b2ec
Merge pull request #8662 from hashicorp/return_with_ssh_wait_timeout
WIP Add ssh_wait_timeout back for backward compatibility
2020-01-28 12:08:42 -08:00
Moss 6ad7f593bf Undo ssh_wait_timeout backward incompatibility 2020-01-28 17:26:01 +01:00
Moss 61bee60ecf Add StepHttpIpDiscover tests 2020-01-28 10:31:17 +01:00
Moss 0566f1f999 Extract http ip discover to a new step 2020-01-27 17:06:56 +01:00
Sylvia Moss d6a351b173
Rename communicator config variables and remove deprecated code (#8584) 2020-01-09 08:37:30 -08:00
Megan Marsh be97507088 delete qmp socket path. Also, clean up unnecessary use of statebag to recieve step values. (#8572) 2020-01-07 11:18:01 +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
Megan Marsh 9fc37f9456
Merge pull request #8438 from hashicorp/fix_qemu_sizes
make sure we continue to default to Megabytes for qemu disk size to p…
2019-12-03 09:58:21 -08:00
Megan Marsh 7d8f1c01c4 Revert "fix: persist default drive/device" (#8440)
This reverts commit 30ccab4 which introduced the issue 8436.
2019-12-03 13:42:11 +01: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
bugbuilder 30ccab472f fix: persist default drive/device 2019-11-17 04:38:30 -03:00
Adrien Delorme db4f242a24 go generate ./builder/qemu after #7676 2019-11-08 11:27:00 +01: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
Adrien Delorme ee6b72570b Update builder.hcl2spec.go 2019-11-05 14:21:07 +01:00
Megan Marsh d010762dbf Revert "Revert "Qemu builder disk size as a string""
This reverts commit 9c782f4d04.
2019-11-04 14:28:48 -08: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
Megan Marsh 9c782f4d04 Revert "Qemu builder disk size as a string"
This reverts commit 1ecfa032ba.
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 a841da960d Merge branch 'master' of ssh://github.com/hashicorp/packer into scrape_doc_to_builder_struct_config 2019-08-30 15:10:29 +02:00
Lars Lehtonen b6eadb419a builder/qemu: Fix dropped error 2019-08-29 05:13:46 -07: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 4b0a7b0af7 Fix QEMU fmt miss 2019-07-10 13:12:31 -06:00
Jayson Cofell f1ad385669 Change QMP socket test to join with filepath 2019-07-10 12:55:44 -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