Commit Graph

335 Commits

Author SHA1 Message Date
Megan Marsh dca2c03cdb
Merge pull request #7866 from hashicorp/sharing_info
Add new struct to Provision() method signature, allowing us to share connection and credential info generated at build time with provisioners.
2019-12-17 14:55:20 -08:00
nywilken 1eb55c2ae3 builder/azure: Remove double override of GalleryImageVersionsClient.PollDuration
This change fixes an issues where custom timeouts set for the
GalleryImagesVersionClient was being over written by the default client
poll duration.
2019-12-17 10:47:32 -05: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
Kris Hicks 40357e2534 docs/builder/azure-arm: Remove errant html comment (#8484)
* Remove errant html comment from source

* make generate
2019-12-13 10:35:24 -05:00
Megan Marsh 3389d843f0 update all provisioners that used the winrmpassword tooling to use the new generateddata option 2019-12-12 16:42:53 -08:00
Megan Marsh 6f418d0e54 get data sharing to a working state with the powershell provisioner 2019-12-11 15:43:38 -08:00
Megan Marsh 601007e3e2 pas data into provisioners well 2019-12-11 15:43:38 -08: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 0e70e0e5a4.
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 44f91c9afc.
2019-11-04 14:28:40 -08:00
Lars Lehtonen 6862e3534f
builder/azure/chroot: fix dropped error 2019-10-30 11:14:32 -07:00
Paul Meyer 3be7d81ce2 Move common steps together 2019-10-24 04:21:46 +00:00
Paul Meyer e6dfe301ac Move CommandWrapper & ShellCommand to common 2019-10-24 04:06:29 +00:00
Paul Meyer b54a2ee09d Set correct user agent for Azure clientset 2019-10-23 11:31:29 -07:00
Megan Marsh 5614f307fb regerate code
generate flat FlatPolicyDocument
add PolicyDocument to generate command
2019-10-23 10:46:07 -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 8b76453e7f make generate 2019-10-16 10:50:45 +02: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 575de8659e
Merge pull request #8226 from larohra/IncreasePollingDuration
[azure] Increase polling duration
2019-10-15 16:25:36 -07:00
Paul Meyer b716299d8e PR comment 2019-10-15 21:14:20 +00:00
Paul Meyer d3dc1be71c Doc updates 2019-10-15 21:14:20 +00: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 fe584f4448 Format updates 2019-10-15 21:14:20 +00:00
Paul Meyer 19a3502b36 Add 'vm' template function 2019-10-15 21:14:20 +00:00
Paul Meyer f72c4ec7a3 Update example and docs 2019-10-15 21:14:20 +00:00
Paul Meyer b5c0742951 Add test that verifies disksize bug (2/2) 2019-10-15 21:14:20 +00:00
Paul Meyer 98175c06d5 Add test that verifies disksize bug (1/2) 2019-10-15 21:14:20 +00:00
Paul Meyer eb5dc9326d Adding more tests 2019-10-15 21:14:20 +00:00
Paul Meyer 5943881051 Default for Gen 1 VMs 2019-10-15 21:14:20 +00:00
Paul Meyer 716f19a457 make fmt 2019-10-15 21:14:20 +00:00
Paul Meyer 8c73450f3d fixup! Add documentation to config struct 2019-10-15 21:14:20 +00:00
Paul Meyer 11ef06b94d Add StepVerifySourceDisk 2019-10-15 21:13:37 +00:00
Paul Meyer cb729e5a38 Add documentation to config struct 2019-10-15 21:13:37 +00:00
Paul Meyer 27a5bfe11c Add implementation for disk as source 2019-10-15 21:13:37 +00:00
Paul Meyer eff3f2bdcf Add test for disk input validation 2019-10-15 21:13:37 +00:00
Paul Meyer 57cff8961a Allow skipping OSDisk cleanup 2019-10-15 21:13:37 +00:00
Paul Meyer 6dee4d2d32 Wait for detach optimization 2019-10-15 21:13:37 +00:00
Paul Meyer bbac79f0a4 Make PIR images work 2019-10-15 21:13:37 +00:00
Paul Meyer b5401d552a Make from_scratch work 2019-10-15 21:13:37 +00:00
Paul Meyer b9b5bb2951 Use DiskStorageAccountTypes 2019-10-15 21:13:37 +00:00
Paul Meyer b4d0865548 Update azure-chroot builder 2019-10-15 21:13:37 +00:00
Paul Meyer e11a5bdb40 Put os disk id in state 2019-10-15 21:13:37 +00:00
Paul Meyer 77b782c5b5 Add StepEarlyCleanup 2019-10-15 21:13:37 +00:00
Paul Meyer 977ca5be1c Add StepCopyFiles and StepChrootProvision 2019-10-15 21:13:37 +00:00