16897 Commits

Author SHA1 Message Date
Larry
20472bc12f
Update provisioner_test.go 2020-08-25 09:49:51 -05:00
Larry
f4a2838716
Added Tests for AnsibleSSHExtraArgs 2020-08-25 08:54:25 -05:00
Larry
7cb17f64a6
Added AnsibleSSHExtraArgs 2020-08-25 08:53:41 -05:00
Adrien Delorme
0d0bd9ce75
name fields of PolicyDocument correctly in HCL (#9812)
withouth this fix we would have had to do

```hcl
  temporary_iam_instance_profile_policy_document {
    statement {
      action   = ["*"]
      effect   = "Allow"
      resource = ["*"]
    }
    version = "2012-10-17"
  }
```

instead of the same document but with capitalised fields
2020-08-25 10:53:56 +02:00
Adrien Delorme
5ba134ac5b
JSON to HCL2 (minimal best-effort) transpiler (#9659)
hcl2_upgrade transforms a JSON build-file in a HCL2 build-file.
This starts a validated Packer core and from that core we generate an HCL 'block' per plugin/configuration. So for a builder, a provisioner, a post-processor or a variable. The contents of each block is just transformed as is and basically all fields are HCL2-ified.
A generated field can be valid in JSON but invalid on HCL2; for example JSON templating (in mapstructure) allows to set arrays of strings - like `x = ["a", "b"]` - with single strings - like `x="a"` -, HCL does not allow this.
Since JSON does not make the distinction between variables and locals, everything will be a variable. So variables that use other variables will not work.
hcl2_upgrade tries to transform go templating interpolation calls to HCL2 calls when possible, leaving the go templating calls like they are in case it cannot.

Work:
* transpiler
* tests
* update hcl v2 library so that output looks great.
* update docs
2020-08-25 10:51:43 +02:00
Megan Marsh
9f2cb0d560
make the default target generate dev builds. (#9811) 2020-08-25 10:11:38 +02:00
Adrien Delorme
a0c09e85df
retry spot instance creation when an "Invalid IAM Instance Profile name" error pops up (#9810)
PutRolePolicy & AddRoleToInstanceProfile are eventually consistent but it is not possible to wait for them to be done here: 0785c2f6fc/builder/amazon/common/step_iam_instance_profile.go (L117-L134) which was causing the `CreateFleet` to fail (100% for me). So for now we retry a bit later. Waiting 5 seconds after the previously linked code also fixed this.

Test file:

```json
{
	"builders": [
		{
			"type": "amazon-ebs",
			"region": "eu-west-1",
			"ami_name": "ubuntu-16.04 test {{timestamp}}",
			"ami_description": "Ubuntu 16.04 LTS - expand root partition",
			"source_ami_filter": {
				"filters": {
					"virtualization-type": "hvm",
					"name": "ubuntu/images/*/ubuntu-xenial-16.04-amd64-server-*",
					"root-device-type": "ebs"
				},
				"owners": [
					"099720109477"
				],
				"most_recent": true
			},
			"spot_price": "0.03",
			"spot_instance_types": [
				"t2.small"
			],
			"encrypt_boot": true,
			"ssh_username": "ubuntu",
			"ssh_interface": "session_manager",
			"temporary_iam_instance_profile_policy_document": {
				"Version": "2012-10-17",
				"Statement": [
					{
						"Effect": "Allow",
						"Action": [
							"*"
						],
						"Resource": "*"
					}
				]
			},
			"communicator": "ssh"
		}
]}
```
2020-08-25 10:10:32 +02:00
Wilken Rivera
1252658848
Merge pull request #9813 from raygervais/documentation/inspec
adds: note in documentation of inspec on host machine required
2020-08-24 16:38:39 -04:00
raygervais
759ae006df adds: note in documentation of inspec on host machine required 2020-08-24 12:39:57 -04:00
Sylvia Moss
2152fa3313
Accept content library path in iso_paths (#9801) 2020-08-24 16:54:30 +02:00
Adrien Delorme
fbfe31ceaf
update flock + go mod tidy (#9805) 2020-08-24 10:49:43 +02:00
Marin Salinas
8166dad533
Merge pull request #5 from marinsalinas/step_cleanup_volumes
refactor: change step_cleanup_volumes to new OSC SDK
2020-08-21 15:03:47 -05:00
Marin Salinas
aba6e104ae
Merge pull request #6 from marinsalinas/step_security_group
Step Security Group
2020-08-21 13:33:30 -05:00
PacoDw
8274d4848c chore: added forece_deregister in the test case to verify the step_deregister_omi 2020-08-21 13:30:21 -05:00
PacoDw
071854ea4a chore: implemented OSC API in step_deregister_omi 2020-08-21 13:29:41 -05:00
PacoDw
a13dfe1f42 chore: added GetRegion() and NewOSCClientByRegion functions 2020-08-21 13:29:27 -05:00
PacoDw
60bd61dc18 chore: removed security group filter function, it was moved to step_security_group file 2020-08-21 11:31:00 -05:00
PacoDw
c3a4b60ea5 chore: implemented OSC API in step_security_group 2020-08-21 11:30:10 -05:00
Marin Salinas
7a45e4c8b0 refactor: change step tag bsu volumes to new OSC SDK 2020-08-21 10:40:14 -05:00
Marin Salinas
c58d6f9b33 refactor: migrate run vm step to new SDK 2020-08-21 10:10:25 -05:00
Adrien Delorme
7de6c21a8a
HCL: document contextual source variable usage (#9799)
It is possible to use ${source.name} and ${source.type}, this was not documented before
2020-08-21 13:37:08 +02:00
Adrien Delorme
f28c06a861
HCL: re-add the option to set a command for inspec (#9800) 2020-08-21 13:32:21 +02:00
Marin Salinas
6f0bb33c9a refactor: change tags ssh file to new OSC SDK 2020-08-20 20:35:51 -05:00
Marin Salinas
e5c14044fb refactor: change tags file to new OSC SDK 2020-08-20 19:12:38 -05:00
Marin Salinas
addc3dd6e7 refactor: change step_cleanup_volumes to new OSC SDK 2020-08-20 18:33:02 -05:00
Marin Salinas
d9a7626249
Merge pull request #4 from marinsalinas/step_public_ip
Step public ip
2020-08-20 18:04:03 -05:00
PacoDw
7745369dce chore: set true associate_public_ip_address attribute to test the step_public_ip 2020-08-20 14:00:13 -05:00
PacoDw
86966ecfee :chore: implemented OSC API in pre_public_ip step 2020-08-20 13:59:25 -05:00
Sylvia Moss
ada2a431ef
Modularise vCenter rest client (#9793) 2020-08-20 17:55:25 +02:00
Sylvia Moss
99800619b7
Add HCL2 examples to the virtualbox builders (#9788) 2020-08-20 15:43:38 +02:00
Megan Marsh
5b27fc7d61 update changelog 2020-08-19 07:43:03 -07:00
Sylvia Moss
a1524bf96a
Add option to also import OVF templates to the Content Library (#9755) 2020-08-19 13:20:25 +02:00
Megan Marsh
01d45d67c8
Merge pull request #9785 from hashicorp/document_7067
document workaround for upstream bug
2020-08-18 14:27:51 -07:00
Marin Salinas
6f6a656486
Merge pull request #3 from marinsalinas/step_key_pair
Step Key Pair
2020-08-18 16:20:35 -05:00
Megan Marsh
6307710485 document workaround for upstream bug 2020-08-18 14:12:14 -07:00
Megan Marsh
229e80bcba
Merge pull request #9784 from hashicorp/cleanup_local_vs_remote_output_directories
implement a remote_output_directory option, and heavily comment outpu…
2020-08-18 14:11:32 -07:00
PacoDw
232d5a3ce6 chore: changed oapi to osc 2020-08-18 15:06:00 -05:00
Megan Marsh
a2cfaace59 extract output dir configuration and defaulting into the step_output_dir, using pointers to make sure they get set properly back on the main config 2020-08-18 12:50:06 -07:00
Megan Marsh
3b2bedf794 implement a remote_output_directory option, and heavily comment output code 2020-08-18 12:50:00 -07:00
PacoDw
43e9d43ebd chore: removed API attribute 2020-08-18 13:52:49 -05:00
Marin Salinas
7d8f28e1a3
Merge pull request #2 from marinsalinas/step_source_info
Step source info
2020-08-18 13:34:16 -05:00
Marin Salinas
8b2cdc5821 refactor: change step_network_info to new OSC SDK 2020-08-18 13:33:45 -05:00
Marin Salinas
8649496c6c refactor: change new sdk on step_source_omi_info 2020-08-18 13:33:45 -05:00
Marin Salinas
daefa4d086 chore: update vendor dependencies 2020-08-18 13:33:45 -05:00
PacoDw
4431bb87b2 :chore: added api key to specify the API connection 2020-08-18 13:33:45 -05:00
PacoDw
823b957a1f :chore: implemented OSC connection in pre_validate file 2020-08-18 13:33:45 -05:00
PacoDw
22481d1ac2 :chore: added OSC Connection in builder file 2020-08-18 13:32:38 -05:00
PacoDw
1fbe715c13 :chore: added OSC Connection in builder file 2020-08-18 12:23:39 -05:00
Wilken Rivera
20eeffee0d
integration/secretsmanager: Add support for AWS SharedConfig file (#9781)
This changes updates the AWS Secrets manager session authentication
logic to support reading the AWS configuration file for default
credentials and region settings, if they are not provided via
environment variables.

* Modify error output a little to remove stutter "error ... : error ...`

Results before change
```
unset AWS_REGION
⇶  ~/pkg/packer build amazon-ebs_secretsmanager_shell-local.json
template: root:1:3: executing "root" at <aws_secretsmanager `packer/test/keys`
`shell`>: error calling aws_secretsmanager: Error getting secret: MissingRegion:
could not find region configuration
```

Results after change
```
unset AWS_REGION
⇶  ~/pkg/packer build amazon-ebs_secretsmanager_shell-local.json
null: output will be in this color.

==> null: Running local shell script: /tmp/packer-shell721444992
    null: powershell
Build 'null' finished after 4 milliseconds 121 microseconds.

==> Wait completed after 4 milliseconds 192 microseconds

==> Builds finished. The artifacts of successful builds are:
```
2020-08-18 10:51:48 -04:00
Megan Marsh
b0d2201d55
Merge pull request #9782 from hashicorp/fix_9151
fully destroy vm if it was cancelled or errored
2020-08-18 07:22:18 -07:00