Commit Graph

50 Commits

Author SHA1 Message Date
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 078ba7c8c3 commit old code generation tool
for history
2019-10-15 12:56:42 +02:00
Robbert Müller 9f972375ed
Removed whitelist check for builders
Fixes https://github.com/hashicorp/packer/issues/8060

Signed-off-by: Robbert Müller <spam.me@grols.ch>
2019-09-04 18:34:39 +02:00
Adrien Delorme a81abd297b Merge remote-tracking branch 'origin/master' into context_provisioner 2019-04-08 20:09:01 +02:00
Adrien Delorme e65115a7a0 contextualize post-processor 2019-04-03 15:55:55 +02:00
Megan Marsh 12fc1fa751 default_keep_input_artifact 2019-04-02 16:51:58 -07:00
dpolitis d1f5312253 fix recurring bug #3878, make destination ESXi host selectable in config, more informative error output 2018-09-10 08:40:03 +03:00
Matthew Hooker c6299972b9
s/boot_command/bootcommand/ 2018-04-19 14:26:31 -07:00
Megan Marsh 6855216387 force QueryEscape to escape spaces as %20 instead of as + for ovftool. 2018-04-06 15:48:04 -07:00
bugbuilder b754b71519 return vsphere artifact to can build template 2017-11-10 22:57:39 -03:00
bugbuilder da54bf8e73 using only remoteFolder as parameter 2017-11-10 14:03:15 -03:00
Matthew Hooker abcc02dc64
filter password from logs 2017-10-24 11:39:04 -07:00
Matthew Hooker 0cf0a4336d
relay ovftool output. 2017-10-23 15:38:57 -07:00
bugbuilder 50904064e1 doesn't keep the original artifact 2017-09-24 21:56:35 -03:00
bugbuilder 75a4ca7351 adding artifact testing and using builder id 2017-09-23 15:43:57 -03:00
bugbuilder 99dd19ccfd Adding correct reference to VM remote path 2017-09-22 23:37:27 -03:00
bugbuilder 24a8fddf03 showing artifact info in packer UI 2017-09-22 13:54:11 -03:00
bugbuilder 644ac5b367 enable vsphere-template to work with local builders 2017-09-20 22:50:37 -03:00
Matthew Hooker 81522dced0
move packer to hashicorp 2017-04-04 13:39:01 -07:00
Matthew Hooker 192d550cd7
filter password in ovtool 2017-02-10 01:01:03 -08:00
Abhijeet Kasurde ba0f202258 Removed redundant print message from post-processor/vsphere
Fixes: https://github.com/mitchellh/packer/issues/3387

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2016-07-18 22:53:05 +05:30
Robert Deusser 9219ffa982 Resolves vsphere post-processor problems (#3321)
* Fixed vsphere post-processor and added logic for optional arguments

* Refactored arg building, and added test for vsphere post-processor
2016-05-18 18:26:46 -07:00
Chris Bednarski dab36cbdee Merge pull request #2304 from eloycoto/master
Post-Processor/Vsphere: Added overwrite option
2016-02-02 14:14:54 -08:00
Jose Cardoso 096b42abce Added support for spaces in vSphere resource pools 2016-01-26 09:41:30 +00:00
Chris S 195405ca5b Update post-processor.go
Added support for spaces for vm folders, datastore names etc. in the ovftool command line arguments.
2016-01-25 17:00:30 +00:00
Eloy Coto 63d21ec9f3 Vsphere post-processor: Fix merge problems 2015-10-29 10:21:30 +00:00
Eloy Coto 0bc042a15c Post-Processor/Vsphere: Added custom options 2015-10-29 09:35:03 +00:00
Eloy Coto 34f163ce87 Post-Processor/Vsphere: Added overwrite option 2015-10-29 09:35:03 +00:00
Yuya Kusakabe 699c673536 builder/vmware-esxi: Add step_export
If `format` option is configured, packer exports the VM with ovftool.

website: Document about OVF Tool and `format` option.

post-processor/vsphere: Enable to use `mitchellh.vmware-esx` artifact type and OVF and OVA formats, fixes #1457.
2015-10-23 09:00:53 +09:00
Mitchell Hashimoto 5db4d7c01f fmt 2015-06-22 12:37:52 -07:00
Mitchell Hashimoto 5241d8c6d6 post-processor/*: fix interpolation context 2015-06-22 12:24:55 -07:00
Salvador Girones 6cb51f21de Make ResourcePool optional 2015-06-22 10:13:49 -07:00
Mitchell Hashimoto dc1e67b6d2 post-processor/*: interpolation 2015-05-27 14:56:22 -07:00
Ryan Breed 514b5f52f1 consistent escaping for ovftool uri creds
I got thrown for a loop since the username is uri-escaped but the password was not.

I got thrown for another couple of loops due to the multiple levels of interpretation involved:
1) JSON syntax requires backslashes to be slash-escaped. Some vCenter deployments use windows domain-style usernames DOMAIN\user
2) the OVFTOOL docs specify that "all special characters" be uri-encoded when part of the user name or password
3) different shell interpretations on windows/linux

I'd say escape both or neither.
2014-11-12 23:03:14 -06:00
hkhkhk1987 f61cc3f99c Update post-processor.go
the ovftool can't refer to an object vi address without a "/" at the end of the address
2014-10-24 15:21:57 +08:00
Misha Brukman c75a671c1e Cleaned up Go formatting with gofmt. 2014-07-17 15:33:09 -04:00
Michael Kuzmin 2dd538ced8 post-processor/vsphere: url-escape username to accept DOMAIN\account values 2014-05-15 16:04:27 +04:00
Michael Kuzmin b05129e52e post-processor/vsphere: logging for upload parameters 2014-05-15 15:53:17 +04:00
Mitchell Hashimoto 3c2df9a132 post-processor/vsphere: comments and style 2014-04-30 15:52:01 -07:00
Michael Kuzmin fce2fc526f Optional parameters in vSphere post-processor.
datastore, vm_folder, and vm_network options can be omitted.
2014-04-30 16:02:09 +04:00
Mitchell Hashimoto c19a5c6bb7 post-processors/vsphere: disk mode 2014-04-21 21:10:20 -07:00
Anthony Spring 41b009dcf1 Add disk mode configuration to allow users to specify the desired diskMode to ovftool: eagerZeroedThick , seSparse, thin and think. Defaults to thick per current ovftool default. 2014-01-03 02:07:36 -05:00
Mitchell Hashimoto fa410f5a1a post-processor/vsphere: template process in prepare phase 2013-12-11 14:01:14 -08:00
mheidenr 9df6b8f0c8 post-processor-vsphere: user variables for datastore 2013-12-02 13:53:13 +01:00
mheidenr 129749a2e4 post-processor-vsphere: user variables for vm_name, username, password 2013-12-02 12:39:52 +01:00
mheidenr 2aaec946b3 fix post-processor vsphere 2013-11-29 17:33:26 +01:00
Mitchell Hashimoto 6867c4f3e3 website: vsphere endpoint docs 2013-11-18 16:23:28 -08:00
Mitchell Hashimoto b52132c650 post-processor/vsphere: cleanups
/cc @mheidenr - Some basic cleanups. :)
2013-11-18 16:04:38 -08:00
Mitchell Hashimoto 7d9b48e7f8 fmt 2013-11-18 15:57:31 -08:00
mheidenr 15766602c7 added post-processor-vsphere 2013-11-11 09:56:51 +01:00