Commit Graph

52 Commits

Author SHA1 Message Date
Sylvia Moss d6a351b173
Rename communicator config variables and remove deprecated code (#8584) 2020-01-09 08:37:30 -08: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
Sylvia Moss c57f093efe
Remove unnecessary source_path validation for virtualbox-ovf (#8489) 2019-12-16 16:50:21 +01:00
Adrien Delorme 078ba7c8c3 commit old code generation tool
for history
2019-10-15 12:56:42 +02:00
Adrien Delorme 74f0d56cfc virtualbox merge vbpx manage configs 2019-06-19 17:07:23 +02:00
Adrien Delorme 01eff9472a virtualbox: merge ExportOpts and ExportConfig structs 2019-06-19 16:35:15 +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
Vadym Haidamaka 0263503c45 Validate virtualbox_version_file and guest_additions_mode when communicator is none 2019-03-16 18:15:27 +02: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 3fd589fa72 typos 2019-02-08 09:31:30 -08:00
Megan Marsh e2d8c0bfd7 docs 2019-02-08 09:28:10 -08:00
Matthew Hooker a0c9ddb9ae
implement boot config struct for virtualbox 2018-04-19 14:26:31 -07:00
Matthew Hooker 49958391b3
better error when source_path doesn't exist. 2018-03-19 09:58:39 -07:00
Ali Rizvi-Santiago c17f827e1d Split up DownloadableURL() into it's individual components: SupportedURL(), DownloadableURL(), and ValidatedURL(). Updated all instances of DownloadableURL() to point to ValidatedURL(). Reverted the tests that are based on un-supported protocols. 2018-01-16 13:37:32 -06:00
Megan Marsh 3ace5bb91b simplify FileExistsLocally 2018-01-10 16:11:17 -08:00
Megan Marsh 216c44b153 fix FileExistsLocally 2018-01-09 15:47:07 -08:00
Megan Marsh 4f3b470804 add helper function to manage validation of filepaths created using DownloadableURL 2018-01-03 16:53:47 -08:00
Megan Marsh 6756df9510 use url library instead of parsing string naiively 2017-11-13 12:57:53 -08:00
Megan Marsh 0d18de2942 do validation in vmx config stage 2017-11-13 12:42:57 -08:00
SLAZ666 f6bb79784f Add option keep_registered to virtualbox-ovf builder 2017-09-13 15:37:26 +02:00
Matthew Hooker 81522dced0
move packer to hashicorp 2017-04-04 13:39:01 -07:00
DanHam 0ac071b6e7
Add option to skip export of installed VM for Virtualbox ISO & OVF builders
Closes #4131
2016-12-29 13:19:59 +00:00
Arthur Burkart 337856811e Implements OVA downloads w/local checksum support
Presumably, it is convention to store a manifest file with checksums
inside the OVA, so remote checksum support was not implemented.
2016-11-28 15:01:37 -05:00
Ricard Clau acededfc6e tests actually test the floppies 2016-07-27 21:59:21 +01:00
Mark Peek 7f149e595d Refactor http server config into common 2015-11-01 14:45:47 -08:00
Mitchell Hashimoto 93bb0d86af builder/virtualbox: fix default names 2015-06-22 09:25:15 -07:00
Mitchell Hashimoto 84189f7a28 builder/*: properly save interpolation context 2015-06-22 09:22:42 -07:00
Mark Peek 16320372d6 Make some builder config usage more consistent with other builders 2015-06-12 14:02:09 -07:00
Mitchell Hashimoto 0dc4226810 builder/virtualbox/ovf: new interpolation 2015-05-27 14:03:56 -07:00
Mitchell Hashimoto c74f0c7cfe Merge branch '1082-add-boot-commands-to-vmx-and-ovf-builders' of github.com:rasa/packer into rasa-1082-add-boot-commands-to-vmx-and-ovf-builders
Conflicts:
	builder/virtualbox/ovf/config.go
	builder/vmware/vmx/config.go
2014-09-05 11:42:01 -07:00
Mitchell Hashimoto 9b2039121f builder/virtualbox-ovf: import_flags [GH-1383] 2014-09-05 10:23:37 -07:00
Ross Smith II e93697ab4e builder/virtualbox-ovf,vmware-vmx: add `boot_command` support
Fixes #1082
2014-05-12 21:19:24 -07:00
Rickard von Essen c2013bf680 virtualbox-ovf support for guest_additions_mode
Fixes #1035 "virtualbox-ovf" builder doesn't support "guest_additions_mode" option
2014-05-04 18:48:41 +02:00
Jacob Helwig 38e880a187 Add ability to run vboxmanage commands just before exporting [GH-664] 2014-04-29 11:58:11 -07:00
Ben Langfeld 0332901f63 builder/virtualbox: Add an `export_opts` option
Allows arbitrary arguments to VBoxManage export, such as product info (--product, --vendor, etc).
2014-03-12 10:12:20 -03:00
Brian Johnson ac2c4203a2 Add import_opts to the virtualbox-ovf builder. My use case is that I
have existing virtualbox virtual machines where I need to keep the mac
addresses so that the network interfaces come up when packer boots them.
Otherwise I just get SSH timeout and I'm unable to configure the machines.
2014-02-18 16:44:27 -08:00
Greg Lu 6d2e50e598 builder/virtualbox/ovf: fix shutdown_timeout handling
The shutdown_timeout config parameter was being ignored
(for both the user setting and the "5m" default) on the
virtualbox-ovf builder. As a result, packer complained
of timeouts on graceful shutdowns, and the build process
would error out. This fixes that along with some newly
created tests.
2013-12-31 18:28:33 -05:00
Mitchell Hashimoto 39d0600085 builder/virtualbox: fmt 2013-12-23 14:21:28 -08:00
Mitchell Hashimoto c2b3fa732a builder/virtualbox/ovf: validate source_path 2013-12-22 17:02:22 -08:00
Mitchell Hashimoto e69bb1858c builder/virtualbox/ovf: specify name for import 2013-12-22 15:24:24 -08:00
Mitchell Hashimoto dd767c9d54 builder/virtualbox/ovf: StepImport to import an OVF 2013-12-22 15:19:19 -08:00
Mitchell Hashimoto e51dde13ce builder/virtualbox: tests for StepUploadVerison 2013-12-22 11:55:01 -08:00
Mitchell Hashimoto 5f1c597269 builder/virtualbox: StepUploadVersion 2013-12-22 11:50:29 -08:00
Mitchell Hashimoto 5feb7bce18 builder/virtualbox/common: Export 2013-12-22 10:40:39 -08:00
Mitchell Hashimoto 026bcd33fe builder/virtualbox: StepRun common 2013-12-22 10:30:12 -08:00
Mitchell Hashimoto 67a87ce3e4 builder/virtualbox: StepShutdown 2013-12-22 09:37:27 -08:00
Mitchell Hashimoto 4bd2aa6106 builder/virtualbox: StepVBoxmanage 2013-12-22 09:24:29 -08:00
Mitchell Hashimoto 7a4ff3f2b1 builder/virtualbox: generic SSHConfig 2013-12-22 09:08:09 -08:00