114 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
Lars Lehtonen
df031db9da builder/azure/common/template: remove unused TemplateBuilder.getResourceByType2() (#8419)
builder/azure/common/template: remove unused TemplateBuilder.toKeyVaultID()
2019-12-02 18:09:42 +01:00
Megan Marsh
d5ba530b26 make it clear we expect pem format not some other formate (#8344) 2019-11-07 10:30:51 +01:00
Megan Marsh
6c704f7046 Revert "fix template imports"
This reverts commit 0e70e0e5a4c570790f7f253e69c6e09ed18e38d1.
2019-11-04 14:29:00 -08:00
Megan Marsh
517834d528 Revert "Revert "remove clean_ami_name and clean_image_name; complete the deprecation for these functions in favor of clean_resource_name""
This reverts commit 44f91c9afc1884132f4d4cc69ceb1e04f4e4664c.
2019-11-04 14:28:40 -08:00
Paul Meyer
b54a2ee09d Set correct user agent for Azure clientset 2019-10-23 11:31:29 -07:00
Megan Marsh
d15f43e4eb
Merge pull request #8232 from hashicorp/artifact-tree
HCL2 configs - part one
2019-10-22 11:54:34 -07:00
Megan Marsh
836aaafaa3
Merge pull request #8203 from sumit-kalra/master
Azure-ARM builder: Deploy NSG if list of IP addresses is provided in config
2019-10-21 11:10:58 -07:00
Adrien Delorme
4542666e25 fix func calls after master merge 2019-10-16 10:40:25 +02:00
Adrien Delorme
cf1555bf17 Merge remote-tracking branch 'origin/master' into artifact-tree 2019-10-16 10:22:56 +02:00
Paul Meyer
9b724d4ca0 Add artifact 2019-10-15 21:14:20 +00:00
Paul Meyer
0866cb3714 Reorganize client/common packages 2019-10-15 21:14:20 +00:00
Paul Meyer
716f19a457 make fmt 2019-10-15 21:14:20 +00:00
Paul Meyer
27a5bfe11c Add implementation for disk as source 2019-10-15 21:13:37 +00:00
Paul Meyer
113dc12346 Add function to detect whether Packer is running on Azure 2019-10-15 21:13:37 +00:00
Paul Meyer
f106adbd12 Add Azure client set for chroot builder 2019-10-15 21:13:37 +00:00
Paul Meyer
2ded8f25ec Add metadata client 2019-10-15 21:13:37 +00:00
Paul Meyer
72fdce09ba Allow GetServicePrincipalToken to be called independently 2019-10-15 21:13:37 +00:00
Adrien Delorme
f8402f1b91 builder.azure.common: make CloudEnvironment private so it doesn't temper with hcl2 code generation
the struct is not read from file but later set after some computations
2019-10-15 12:56:41 +02:00
Megan Marsh
0e70e0e5a4 fix template imports 2019-10-14 13:22:06 -07:00
Megan Marsh
44f91c9afc Revert "remove clean_ami_name and clean_image_name; complete the deprecation for these functions in favor of clean_resource_name"
This reverts commit 0026792d2f60f03abc04239640065e967581310c.
2019-10-14 13:08:15 -07:00
Sumit Kalra
595b103bbe
Adding NSG to the ARM deployment template when needed (#3)
* Adding NSG to the ARM eployment template when needed

* Adding tests and fixing bugs

* Removing denyall rule

* Fixing logic to determine which port to open

* Fixing config description
2019-10-08 14:56:43 -07:00
Adrien Delorme
d4600a7716 fix go imports 2019-10-04 11:19:45 +02:00
Megan Marsh
0026792d2f remove clean_ami_name and clean_image_name; complete the deprecation for these functions in favor of clean_resource_name 2019-10-03 15:49:01 -07:00
Paul Meyer
c72a612b44 Re-added tests for FillParamters 2019-09-25 20:33:38 +00:00
Paul Meyer
094a8840d8 Improve comments for FillParameters 2019-09-25 20:33:38 +00:00
Paul Meyer
feeae1514e Refactor client config 2019-09-25 20:33:38 +00:00
Amrita Dutta
85036231c4 Final commit 2019-06-21 02:47:39 +00:00
Amrita Dutta
76dbf4fb3b Remove subscription id from SIG destination input 2019-06-19 06:10:18 +00:00
Amrita Dutta
59a0f7f6e6 add validation checks for replication regions + formatting 2019-06-18 05:34:26 +00:00
Amrita Dutta
34dac69112 pass subscription id via state bag 2019-06-17 22:08:10 +00:00
Ubuntu
6504d3ae5c Changes to ARM builder for publishing to SIG 2019-06-14 21:54:27 +00:00
Amrita Dutta
700c95c613 Update Azure SDK for Go to v30.0.0 2019-05-30 21:25:43 +00:00
Megan Marsh
3e73abc93a refresh line endings 2019-05-17 14:58:20 -07: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
Megan Marsh
ce71932f95
Merge pull request #7061 from boumenot/pr-6773-caching-type
azure: configuration for disk caching
2018-12-06 15:06:21 -08:00
Ali Rizvi-Santiago
1a3c3f2ffc Replaced all instances of mitchellh/go-homedir with an implementation based on os/user. 2018-12-04 16:53:33 -06:00
Christopher Boumenot
c7d8f4e150 azure: configuration for disk caching
Export a configuration knob to change the disk caching setting. The
default value remains ReadWrite.  This seems the most appropriate value
given Packer.  Certain disk sizes require that disk caching be disable,
and this knob allows the user to do just that.
2018-11-30 14:14:43 -08:00
Amrita Dutta
1fa9f1ef11 formatting changes in stateBag.go 2018-11-07 18:11:48 +00:00
Amrita Dutta
d12d23d34b OS disk snapshot 2018-11-05 23:48:22 +00:00
mbearup
de8d30d77c Update tests for Azure Shared Image Gallery 2018-10-10 09:20:34 -07:00
mbearup
c7180413b0 Fix tests for Shared Image Gallery 2018-10-09 16:38:50 -07:00
mbearup
335feaf89c Convert shared_image_gallery options to a struct
Updates tests and documentation for shared_image_gallery
2018-10-09 13:56:49 -07:00
mbearup
c1e0146d33 Dynamically set apiVersion for Shared Image Gallery scenario. 2018-10-03 16:33:28 -07:00
mbearup
d21b13cb85 Modify variable names for Shared Image Gallery.
Add checks for Shared Image Gallery options.
2018-10-03 16:10:46 -07:00
mbearup
55be0da5da Initial changes to support Shared Image Gallery 2018-09-30 13:56:44 -07:00
Adrien Delorme
170b2f3383 builder/azure/common.RandomString-> common/random.String
* to share them
* also removed unused PassworString func & arm.TempPasswordAlphabet package const
2018-09-05 10:24:28 +02:00
Adrien Delorme
7c358eed2f removed unused builder/azure/common/lin.StepGeneralizeOS struct 2018-08-29 14:40:33 +02:00
Adrien Delorme
3d46fbd4f2 removed unused builder/azure/common/lin.StepCreateCert struct 2018-08-29 14:40:33 +02:00
Adrien Delorme
b83c72fd54 more private keys in config 2018-08-29 14:40:32 +02:00