Commit Graph

40 Commits

Author SHA1 Message Date
James Bardin db42015342 backoff retries in remote-exec provisioner
Add a simple backoff to the remote-exec retryFunc.
Backoff between tries, up to a 10s max.
2017-08-09 15:54:08 -04:00
Sander van Harmelen 0e422737ba Fix and refactor the Chef provisioner
The tests did pass, but that was because they only tested part of the changes. By using the `schema.TestResourceDataRaw` function the schema and config are better tested and so they pointed out a problem with the schema of the Chef provisioner.

The `Elem` fields did not have a `*schema.Schema` but a `schema.Schema` and in an `Elem` schema only the `Type` field may (and must) be set. Any other fields like `Optional` are not allowed here.

Next to fixing that problem I also did a little refactoring and cleaning up. Mainly making the `ProvisionerS` private (`provisioner`) and removing the deprecated fields.
2017-05-19 21:05:21 +02:00
Vladislav Rassokhin f5449a62e0 Various built-in provisioners improvements:
1. Migrate `chef` provisioner to `schema.Provisioner`:

 * `chef.Provisioner` structure was renamed to `ProvisionerS`and  now it's decoded from `schema.ResourceData` instead of `terraform.ResourceConfig` using simple copy-paste-based solution;
 * Added simple schema without any validation yet.

 2. Support `ValidateFunc` validate function : implemented in `file` and `chef` provisioners.
2017-05-19 20:43:51 +02:00
Jake Champlin 7e5eeb2268
provisioner/remote-exec: Fix panic from remote_exec provisioner
Fixes panic on `nil` values of `inline` and `scripts` from improper interface casts.

Fixes: #13970
2017-05-01 16:48:42 -04:00
James Bardin 197f6cab79 Cannot store multiple types in atomic.Value
Storing error values to atomic.Value may fail if they have different
dynamic types. Wrap error value in a consistent struct type to avoid
panics.

Make sure we return a nil error on success
2017-02-07 19:02:04 -05:00
Mitchell Hashimoto 640faf18c3
Revert "provisioner/remote-exec: fail on first inline script with bad exit code (#11155)"
This reverts commit d2047d714e.
2017-02-06 16:51:51 -08:00
Mitchell Hashimoto 142df657c3
provisioners/remote-exec: listen to Stop 2017-01-26 15:10:30 -08:00
Mitchell Hashimoto 487a37b0dd
helper/schema: PromoteSingle for legacy support of "maybe list" types 2017-01-26 15:09:15 -08:00
Mitchell Hashimoto 3c0c81957a
provisioners/remote-exec: switch to helper/schema 2017-01-26 15:09:15 -08:00
Peter McAtominey d2047d714e provisioner/remote-exec: fail on first inline script with bad exit code (#11155)
The provisioner collected all inline commands into a single script which meant
only the exit code of the last command was actually checked for an error.
2017-01-20 14:04:43 +00:00
Mitchell Hashimoto 4b1d9cfd7d
communicator/ssh: don't share rand object to guarantee unique values
Fixes #10463

I'm really surprised this flew under the radar for years...

By having unique PRNGs, the SSH communicator could and would
generate identical ScriptPaths and two provisioners running in parallel
could overwrite each other and execute the same script. This would
happen because they're both seeded by the current time which could
potentially be identical if done in parallel...

Instead, we share the rand now so that the sequence is guaranteed
unique. As an extra measure of robustness, we also multiple by the PID
so that we're also protected against two processes at the same time.
2016-12-06 00:21:49 -08:00
Paul Hinze 579680cebc provisioner/remote-exec: Move script cleanup after command wait
The script cleanup step added in #5577 was positioned before the
`cmd.Wait()` call to ensure the command completes. This was causing
non-deterministic failures, especially for longer running scripts.

Fixes #5699
Fixes #5737
2016-03-21 10:49:32 -05:00
Paul Hinze 96ebf0af0e provisioner/remote-exec: Clear out scripts after uploading
Prevents residual script contents from remaining on machine.

Fixes #482
2016-03-11 10:25:11 -06:00
Sam Boyer b82bd0c280 Condense switch fallthroughs into expr lists 2015-05-26 21:52:36 -04:00
Sander van Harmelen 41748003c0 Updated the PR according to the review comments
* We now return an error when you set the script_path to
C:\Windows\Temp explaining this is currently not supported
* The fix in PR #1588 is converted to the updated setup in this PR
including the unit tests

Last thing to do is add a few tests for the WinRM communicator…
2015-05-01 18:52:01 +02:00
Sander van Harmelen b1c6a3f63f Few small fixes to make the last tests also pass
The reason why the shebang is removed from these tests, is because the
shebang is only needed for SSH/Linux connections. So in the new setup
the shebang line is added in the SSH communicator instead of in the
resource provisioner itself…
2015-05-01 18:48:54 +02:00
Sander van Harmelen c9e9e374bb Adding some abstractions for the communicators
This is needed as preperation for adding WinRM support. There is still
one error in the tests which needs another look, but other than that it
seems like were now ready to start working on the WinRM part…
2015-05-01 18:48:54 +02:00
Mitchell Hashimoto de8666a5fa helper/ssh: add random number to script [GH-1545] 2015-04-18 16:09:08 -07:00
Tarrant 05407296c6 Add cleanup function to close SSHAgent 2015-03-20 18:18:35 -07:00
Tarrant 164f303da4 Add SSH Agent support 2015-03-15 16:12:59 -07:00
Mitchell Hashimoto 539eca5ee6 Fix failing tests 2014-10-09 21:29:21 -07:00
Mitchell Hashimoto a154520ce8 provisioners/remote-exec: output 2014-10-05 23:23:30 -07:00
Mitchell Hashimoto e5868ebdd9 provisioners/*: new interface 2014-10-04 16:29:33 -07:00
Mitchell Hashimoto c452579512 provisioners/*: compiling, tests passing 2014-09-16 17:08:27 -07:00
bdd 4a53f38d3a Update resource_provisioner.go
Better variable name.
2014-08-25 17:39:46 -04:00
bdd b2ff49be2e More descriptive variable names for pipes. 2014-08-25 12:39:07 -04:00
bdd 6da9a2d49d Use scanner instead of buffer read line
Supported in Go 1.1 http://golang.org/pkg/bufio/#Scanner
2014-08-25 11:58:14 -04:00
Alex Gaynor 46154ca1d3 Fixed a ton of typos in docs and comments 2014-08-07 00:19:56 -07:00
Mitchell Hashimoto 8720d2465e builtin/provisioners/*: new API 2014-07-22 10:38:39 -07:00
Armon Dadgar b84814539f Refactor shared SSH setup code 2014-07-16 10:33:44 -07:00
Armon Dadgar 2c3e619960 Removing unused constants 2014-07-16 10:33:44 -07:00
Armon Dadgar 8691a3ce91 Refactor helper methods out of provisioner 2014-07-16 10:33:44 -07:00
Armon Dadgar 104b28e19e terraform: Remove ResourceConnectionInfo, use raw map 2014-07-15 12:34:07 -07:00
Armon Dadgar de8ee65b2b provisioner/remote-exec: Retry SSH connections 2014-07-15 12:34:07 -07:00
Armon Dadgar 2b6d7dc0b9 provisioner/remote-exec: Adding retry logic 2014-07-15 12:34:07 -07:00
Armon Dadgar 389d9ba2fc provisioner/remote-exec: First pass at copy+exec 2014-07-15 12:34:07 -07:00
Armon Dadgar f215d31df4 provisioner/remote-exec: Collect scripts to upload 2014-07-15 12:34:07 -07:00
Armon Dadgar cd3170b906 provisioner/remote-exec: Working on SSH configuration 2014-07-15 12:34:07 -07:00
Armon Dadgar 5023b896ab provisioner/remote-exec: Enforce XOR of command and inline 2014-07-15 12:34:07 -07:00
Armon Dadgar 6381fbd226 provisioner/remote-exec: Adding initial skeleton 2014-07-15 12:34:06 -07:00