This reverts commit 334f399ee3, reversing
changes made to 45a5d28bad.
When testing against Windows SSH the Powershell script fails to parse
the newly added if statement.
`env:COMPUTERNAME` give you the first 15 characters of the machine name (the NetBIOS name).
But normally its pretty nice to get the full DNS name. We can solve this in this way.
This change sets the ErrorActionPreference and wraps the script execution in a Try/Catch statement so that the provisioner can capture any errors encountered when running the script. In addition to the try/catch the `&` operator is replaced by the `.` sourcing operator to ensure the script is executed in the same scope as the parent command (so that errors bubble up properly).
Tests after change
```
⇶ ACC_TEST_BUILDERS=amazon-ebs ACC_TEST_PROVISIONERS=powershell go test ./provisioner/powershell/... -timeout=1h
ok github.com/hashicorp/packer/provisioner/powershell 915.865s
```
* Interpolate generatedData in the Inspec provisioner
* Add inspec license section to inspec docs
* add user arg if user config it not empty
* increase resource size for check-lint pipeline
* update changelog
* Update provisioner/inspec/provisioner.go
* Update provisioner/inspec/provisioner.go
Co-authored-by: Megan Marsh <megan@hashicorp.com>
This change reduces the retry timeout from 5m to 1m, and sets the
RetryDelay to 10s for a total of 6 retries. In additional to the retry
time reduction the cleanup script will now check to see if the
provisioner script created by Packer exists before trying to delete to
prevent any file not found issues.
Closes#9181Closes#9189
* mapstructure-to-hcl2: when we see a map generate an attribute spec and not a block spec
this will alow to do
tags = {
key = "value"
}
instead of
tags {
key = "value"
}
This will also enable using variables directly for those tags
* generate code
* update tests
* Add retry logic so that the provisioner will retry if it fails to upload/execute because of some restart provisioner step
* Add a testConfigWithSkipClean for testing that the provisioner executes the correct commands
* Add a test case for toggling the "skip_clean" config option
This function can be used to check if a Provisioner has been marked for testing within the ACC_TEST_PROVISIONERS environment variable.
While testing I found that the shell acceptance test were also running when trying to run powershell tests.
Before change
```
⇶ ACC_TEST_BUILDERS=amazon-ebs ACC_TEST_PROVISIONERS=powershell go test -v ./provisioner/shell/... -timeout=1h
=== RUN
TestShellProvisioner/testing_amazon-ebs_builder_against_shell_provisioner
2020/04/06 15:18:12 ui: amazon-ebs: output will be in this color.
2020/04/06 15:18:12 ui:
2020/04/06 15:18:12 Build debug mode: false
2020/04/06 15:18:12 Force build: false
2020/04/06 15:18:12 On error:
2020/04/06 15:18:12 Preparing build: amazon-ebs
2020/04/06 15:18:12 Waiting on builds to complete...
2020/04/06 15:18:12 Starting build run: amazon-ebs
2020/04/06 15:18:12 Running builder: amazon-ebs
```
After changes
```
⇶ ACC_TEST_BUILDERS=amazon-ebs ACC_TEST_PROVISIONERS=powershell go test -v ./provisioner/shell/... -timeout=1h
--- SKIP: TestShellProvisioner (0.00s)
provisioners.go:88: Provisioner "shell" not defined in ACC_TEST_PROVISIONERS
```
* Modifies the amazon-ebs builder with a windows build configuration
```
⇶ ACC_TEST_BUILDERS=amazon-ebs ACC_TEST_PROVISIONERS=powershell go test -v ./provisioner/powershell/... -run=TestPowershellProvisioner_Inline
--- PASS: TestPowershellProvisioner_Inline (256.50s)
--- PASS: TestPowershellProvisioner_Inline/testing_amazon-ebs_builder_against_powershell_provisioner (256.50s)
PASS
ok github.com/hashicorp/packer/provisioner/powershell 256.525s
```