Commit graph

621 commits

Author SHA1 Message Date
haoshuwei
37dc411f30 add skip_image_validation arg to use an expired image as the soure image
Signed-off-by: haoshuwei <haoshuwei24@gmail.com>
2019-12-20 11:28:31 +08:00
Megan Marsh
b23425f637 use pointer to config rather than config 2019-12-19 11:27:21 -08: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
39fd462b56 change all provision func signatures to use map[string]interface{} 2019-12-12 15:38:32 -08:00
Lars Lehtonen
20d375f705
post-processor/digitalocean-import: drop unused test functions 2019-12-10 06:59:24 -08:00
Lars Lehtonen
d7eee558a6 post-processor/docker-import: drop unused test functions (#8465) 2019-12-09 16:05:03 +01:00
Lars Lehtonen
4fe34a5dc3 post-processor/docker-push: drop unused test helper functions (#8456) 2019-12-06 11:07:51 +01:00
Lars Lehtonen
8146b39986 post-processor/docker-save: remove unused test functions (#8447) 2019-12-05 11:28:38 +01:00
Adrien Delorme
b4200c3590 go generate for the google compute export post processor after #8388 2019-12-02 11:32:16 +01:00
Taneli Leppä
e1cb0c5f7e Added support for specifying Service Account in Google Compute exporter post-processor. (#8388) 2019-12-02 11:29:34 +01:00
henry-aj-jones
d317d7f3d1 post-processor/docker-tag: Allow to tag an artifact with multiple tags (#8392) 2019-11-22 11:48:36 +01:00
Lars Lehtonen
2e7ba19d8c post-processor/vagrant-cloud: fix dropped test errors 2019-11-15 11:44:33 +01:00
Megan Marsh
fcb65ee422
Merge pull request #8307 from hashicorp/fix_8116
delete amazon import post-processor intermediary snapshots
2019-11-01 14:55:22 -07:00
Megan Marsh
e9e4c102e5 delete amazon import post-processor intermediary snapshots 2019-11-01 14:17:44 -07: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
mingsheng.su
4f140d0071 fix docs of ucloud-uhost 2019-10-30 15:05:54 +08:00
mingsheng.su
545575b879 optimize code about ufile config 2019-10-29 16:11:44 -07:00
mingsheng.su
37e898e115 optimize code style 2019-10-29 16:11:44 -07:00
mingsheng.su
1099777978 update bucket about no create 2019-10-29 16:11:43 -07:00
mingsheng.su
083d7896f4 update message of ucloud import 2019-10-29 16:11:43 -07:00
mingsheng.su
2c513fce64 update ucloud packer 2019-10-29 16:11:43 -07:00
mingsheng.su
61f9d3a9fe add ucloud import 2019-10-29 16:11:43 -07:00
Lars Lehtonen
5edabfc849 post-processor/compress: fix dropped errors 2019-10-28 16:19:46 -07:00
Adrien Delorme
078ba7c8c3 commit old code generation tool
for history
2019-10-15 12:56:42 +02:00
Adrien Delorme
771a6e55ef pp.google.[import|export]: unexport Account field
so it doesnt temper with hcl2 cfg generation
2019-10-15 12:56:42 +02:00
Adrien Delorme
af08e2a410 pp.alicloud-import: remove duplicate AlicloudImageName field
( already defined in packerecs.Config )
2019-10-15 12:56:42 +02:00
Andrew Starr-Bochicchio
ae1bb856a3 digitalocean-import: Fix panic when 'image_regions' not set (Fixes: #7843). 2019-10-01 21:14:15 -04:00
Lars Lehtonen
21f2e67462
post-processor/vagrant-cloud: fix dropped errors 2019-09-26 09:23:09 -07:00
Megan Marsh
3c14c50aba Allow user to real oauth token from properly configured Vault instance 2019-09-23 13:26:03 -07:00
Megan Marsh
61b237b6f7
Merge pull request #8097 from onematchfox/vagrant-cloud
post-proc(vagrant-cloud) allow blank access_token (no auth) for private vagrant box hosting
2019-09-19 11:19:57 -07:00
Megan Marsh
9e28b2f5cf fix post-processor 2019-09-16 13:45:28 -07:00
Brian Fox
331babc2ce allow blank access_token (no auth) for private vagrant box hosting 2019-09-12 12:37:53 +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
DanHam
ca9b500e76
Fix test output: Correct copy/paste errors and make message clearer 2019-08-22 09:48:32 +01:00
DanHam
7770ade74c
Clearer error message for artifice users. OCD nits and logging 2019-08-21 14:32:26 +01:00
DanHam
e9ab2203ba
Should return provider correctly with artifacts from other builders or pp's 2019-08-21 14:32:25 +01:00
DanHam
e8336039d9
Should return provider correctly with good box and artifice pp 2019-08-21 14:32:25 +01:00
DanHam
aee400836f
Should return an error if the provider kv pair is not in the metadata file 2019-08-21 14:32:25 +01:00
DanHam
a7603f63c7
Should return an error if the metadata file has badly formatted JSON 2019-08-21 14:32:25 +01:00
DanHam
57137c6e33
Should return an error if the value of the provider key is empty 2019-08-21 14:32:25 +01:00
DanHam
d1327fe422
Should return an error if the metadata file is empty 2019-08-21 14:32:24 +01:00
DanHam
a9e22a6bb2
Should return the provider by parsing the json in the box metadata file 2019-08-21 14:32:24 +01:00
DanHam
0bf0e7c078
Should return an error when the metadata file is not in the box tar archive
Split out box creation into new helper function
2019-08-21 14:32:24 +01:00
DanHam
063e4bd3e5
Should return an error if the box tar archive is empty 2019-08-21 14:32:24 +01:00
DanHam
9c6b355088
Should return an error if the box is a plain gzip file 2019-08-21 14:32:24 +01:00
DanHam
35d326de39
Add basic workings to function. Return an error if box file is empty 2019-08-21 14:32:23 +01:00
DanHam
6b5cf6dcb2
Should return an error when the box file is missing 2019-08-21 14:32:23 +01:00
DanHam
e8c586175e
Intention: Allow use of artifice pp with vagrant-cloud pp
The Vagrant-Cloud and Vagrant provider (e.g. virtualbox, vmware_desktop
etc.) must be determined differently depending on the builder or
post-processor supplying the artifact.

Adds a wrapper function that:

* Uses the original method of determining the provider when the artifact
  is provided by either the Vagrant builder or Vagrant post-processor
* Uses a new (currently empty) function when the artifact is provided
  via the Artifice post-processor
2019-08-21 14:32:23 +01:00
DanHam
3f4f429c3d
Should return an error when artifact file does not have .box extension 2019-08-21 14:32:23 +01:00
DanHam
57308b0126
Should return an error with an invalid BuilderId 2019-08-21 14:32:23 +01:00
DanHam
1bffdd9bff
Add option to allow box Vagrantfile to be dynamically generated during build 2019-08-13 09:09:28 +01:00
DanHam
19f3a63ee1
Tests: Should not error when template is to be created during build 2019-08-13 09:09:28 +01:00
DanHam
4b042ac402
Tests: Should not error when vagrantfile_template exists 2019-08-13 09:09:27 +01:00
DanHam
8ddbb791a1
Fix typo 2019-08-05 17:25:21 +01:00
Megan Marsh
a87ce366b3
Merge pull request #7835 from hashicorp/google_oauth
replace some bespoke google auth code with code from golang's oauth2 …
2019-07-08 09:48:27 -07:00
Megan Marsh
0dfb3cc56f replace some bespoke google auth code with code from golang's oauth2 library 2019-07-03 14:27:33 -07:00
Marc Falzon
d82c4f0057 fixup! fixup! fixup! fixup! Add Exoscale Import post-processor 2019-07-03 09:28:42 +02:00
Marc Falzon
9ce5f5dcee fixup! fixup! fixup! Add Exoscale Import post-processor 2019-07-02 10:15:09 +02:00
Marc Falzon
00c2df24df Add Exoscale Import post-processor
This change adds a new `exoscale-import` post-processor allowing users
to create Private Templates on Exoscale.
2019-07-01 08:40:26 +02:00
chhaj5236
6b081cc41c
update alicloud builder to use official SDK (#7477) 2019-04-26 10:37:49 +08:00
Adrien Delorme
aee73d745d update code after go mod update 2019-04-11 14:19:24 +02:00
Adrien Delorme
d72040f4fa move retry code into the common/retry pkg and make retry context aware 2019-04-09 17:46:38 +02:00
Adrien Delorme
f555e7a9f2 allow a provisioner to timeout
* I had to contextualise Communicator.Start and RemoteCmd.StartWithUi
NOTE: Communicator.Start starts a RemoteCmd but RemoteCmd.StartWithUi will run the cmd and wait for a return, so I renamed StartWithUi to RunWithUi so that the intent is clearer.
Ideally in the future RunWithUi will be named back to StartWithUi and the exit status or wait funcs of the command will allow to wait for a return. If you do so please read carrefully https://golang.org/pkg/os/exec/#Cmd.Stdout to avoid a deadlock
* cmd.ExitStatus to cmd.ExitStatus() is now blocking to avoid race conditions
* also had to simplify StartWithUi
2019-04-08 20:09:21 +02:00
Adrien Delorme
a81abd297b Merge remote-tracking branch 'origin/master' into context_provisioner 2019-04-08 20:09:01 +02:00
Megan Marsh
9dafa310f3 remove redundant keep_input_artifact code from googlecompute-export and googlecompute-import pps. The behavior coded here was already enforced by the core postprocessor code in packer/build.go 2019-04-03 12:05:38 -07:00
Megan Marsh
1b77b05ce2 remove redundant keep_input_artifact from compress pp and clarify keep behavior in shell-local pp 2019-04-03 12:03:40 -07:00
Megan Marsh
056fcb7cea fix tests and add a few new ones 2019-04-03 11:32:49 -07:00
Adrien Delorme
c4f3dccc14 rename interpolation context from ctx to ictx and contexts to ctx to avoid conflicts 2019-04-03 15:56:15 +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
Megan Marsh
2c67cd966b
Merge pull request #7396 from c0sco/amazon-import-encryption
Support S3 and AMI encryption in amazon-import post-processor
2019-03-25 17:24:49 -06:00
Megan Marsh
24c42e4a1f
Merge pull request #7397 from vhaidamaka/fix-7321
Add vagrant-cloud post-processor support for the vagrant builder
2019-03-15 16:00:05 -07: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
Vadym Haidamaka
4855bc79c9 Add vagrant-cloud post-processor support for the vagrant builder 2019-03-12 05:33:46 +02:00
Matt Stofko
ab4382360d Support S3 and AMI encryption 2019-03-11 13:21:47 -07:00
Megan Marsh
67fe820465
Merge pull request #7361 from hashicorp/fix_insecure_skip_tls_verify
fix proxy and tls
2019-03-07 09:21:06 -08:00
Davi Vidal
b0e3128125 Improves test message 2019-03-05 14:39:50 +01:00
Davi Vidal
1a94ad14bd Adds test for insecure_skip_tls_verify 2019-03-05 14:37:37 +01:00
Davi Vidal
a2fd287e56 Ignores SSL verification when on premise vagrant cloud 2019-03-05 10:57:11 +01:00
Megan Marsh
3ed9fe6dee remove unused imports
remove HttpClientWithEnvironmentProxy from amazon builders; let access config handle it
2019-03-04 16:42:33 -08:00
Arnaud Dezandee
f9ae926d8f
googlecompute-export: set network project id to builder 2019-03-01 15:12:31 +01:00
Megan Marsh
be21850e32
Merge pull request #7060 from andrewsomething/do-post-processor
Add digitalocean-import post-processor.
2019-02-14 11:58:00 -08:00
Andrew Starr-Bochicchio
37b3305301 Better varibable naming. 2019-02-13 18:55:27 -05:00
Andrew Starr-Bochicchio
ee430d9a40 Only filter on suffix if more than one file. 2019-02-12 20:20:39 -05:00
Andrew Starr-Bochicchio
203b6ca8b4 Prefix env vars w/ 'DIGITALOCEAN_' 2019-02-11 18:20:35 -05:00
Megan Marsh
6cac03044f
Merge pull request #7248 from oceyral/oceyral/feat/add_user_data
Add "custom_data" key to packer manifest post-processor
2019-02-01 11:37:44 -08:00
Olivier Ceyral
4d10d668ee Add "custom_data" key to packer manifest 2019-02-01 10:41:34 +01:00
Megan Marsh
eef4fc7a01
Merge pull request #7222 from Adezandee/gce-post-processors
googlecompute-postprocessors: service account and export configs
2019-01-31 16:58:42 -08:00
Megan Marsh
035c3506ba manually set proxyfromenvironment in default http client for ec2 sessions 2019-01-25 12:33:25 -08:00
Megan Marsh
c63b54a1e7 move http with proxy call into a helper function 2019-01-25 12:32:52 -08:00
Arnaud Dezandee
8975f67901
googlecompute-export: add exporter instance configs 2019-01-25 11:36:18 +01:00
Arnaud Dezandee
91d2cb8c83
googlecompute-import: add service accounts 2019-01-25 11:36:18 +01:00
Arnaud Dezandee
3d41cdfacb
googlecompute-import: add guest os features 2019-01-22 18:42:38 +01:00
Rickard von Essen
a02bd23f56
When import task fails show the StatusMessage
This will hopefully tell the user the reason of the failure.
2019-01-17 13:36:44 +01:00
Adrien Delorme
9f7b4ffc17
Merge branch 'master' into pr/6950 2019-01-09 10:11:18 +01:00
Ladar Levison
3cc83167c8 Added map structure type to config changes. 2018-12-18 00:48:58 -06:00
Ladar Levison
6ac5971288 Fixed cmd order for docker driver. Added config to post proc. 2018-12-17 22:59:41 -06:00