Commit Graph

209 Commits

Author SHA1 Message Date
Mitchell Hashimoto 0da5d7b650 communicators/ssh: clean error on max session [GH-4044] 2014-08-08 09:11:25 -07:00
Mitchell Hashimoto 5ed0b22c78 communicators/ssh: cleaner error if remote disconnect [GH-4038] 2014-08-07 11:53:44 -07:00
William E. Triest. III 4a2566c646 Fixes 4309
When the winrm communicator executes a command in an elevated shell,
this patch causes it to escape double quotes.

This is necessary as the first line in the file that it produces and
then executes it puts the command into a variable called command that
is delimited by double quotes.
2014-08-07 08:49:36 -04:00
Mitchell Hashimoto 00bd226fc7 guests/nixos: don't detect as Windows [GH-4302] 2014-08-06 11:17:41 -07:00
Mitchell Hashimoto 94841ef1bc Merge pull request #4094 from mitchellh/improved-winrm-command-failure-messaging
provisioners/winrm: Better WinRM command failure messaging
2014-08-06 10:44:35 -07:00
Richard Guin 120b15bc39 Modified WinRM rm filter to account for -f switch, handle recurse properly 2014-07-30 15:43:37 -04:00
Richard Guin 361d41527a Added mkdir command filter for WinRM to be compatible with PS4+ 2014-07-30 15:43:11 -04:00
jdmulloy 50d0861de4 Removed extra n from the word "connection"
Removed extra n from the word "connection" in "Attempting SSH connection" in logger call.
2014-06-27 19:27:23 -04:00
Shawn Neal c72a412600 Better WinRM command failure messaging
Command failures include the stdout and stderr in the error message just like the SSH communicator.
Its now possible to specify only an error_class and have that use the correct error_key by default.
2014-06-24 10:09:11 -07:00
Shawn Neal 291f01045b Fixed issue 3918
Running Windows guest commands through a scheduled task were not returning the correct exit codes, they were only returning 1 or 0. This has negative consequences especially for Puppet which can return an exit code of 2 for partial success.

Since we're running an executable from inside a powershell encoded command we need to ensure we explicitly propagate the exit code to the original caller just like a regular PowerShell script - in this case cmd /c which in return is called from a scheduled task.
2014-05-28 08:54:36 -07:00
Kalman Hazins bb052366f7 Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
Mitchell Hashimoto d7fa60b5df communicators/winrm: use winrm_info cap if available [GH-3832] 2014-05-20 20:13:36 -07:00
Mitchell Hashimoto 0485413d0a Merge pull request #3847 from mitchellh/command-line-too-long-fix-for-winrm
guests/windows: fix #3816 long arg list
2014-05-20 19:38:53 -07:00
Mitchell Hashimoto 690c119ae2 communicators/winrm: don't look up forwarded port if non-local [GH-3861] 2014-05-20 19:30:53 -07:00
Shawn Neal 0d3979f80d Fixed issue 3816
Elevated command line is now rendered to a script which is uploaded to the guest and executed. This allows the command line itself to be less than 100 chars to start the script and any user commands are puts into the script which has unlimited* length.
2014-05-19 08:04:59 -07:00
Shawn Neal 823e80fa32 Fixed issue 3729
The logic used to read the file contents sometimes would leave lines behind unread. It now defaults to reading all lines and counts each line it has actually read.
2014-05-15 09:17:57 -07:00
Mitchell Hashimoto 782c3762cc communicators/ssh: rescue another exception for reset 2014-05-09 15:59:15 -07:00
Mitchell Hashimoto b47df84887 communicators/winrm: fix tests 2014-05-07 10:09:14 -07:00
Mitchell Hashimoto 882c9ad7f6 communicators/winrm: good_exit option 2014-05-07 09:47:47 -07:00
Mitchell Hashimoto 604ae6caa3 communicators/ssh: detect if config.ssh.shell is non-functional [GH-3040] 2014-05-01 21:35:02 -07:00
Shawn Neal 30b0399431 Use new Ruby hash initializer syntax 2014-04-26 21:07:26 -07:00
Shawn Neal f18a397289 Allow WinRM commands to be run elevated via scheduled task 2014-04-26 21:07:26 -07:00
Shawn Neal 1dd081d866 Don't use interpolated strings for username and password
Its possible that usernames and passwords may contain special characters like $
2014-04-26 21:07:26 -07:00
Shawn Neal 045e06455a Added WinRM elevated shell wrapper script
This script creates an immediately run scheduled task using fresh credentials. This is a generic implementation used by the Chef provisioners. The script gets around several limitations in WinRM.

1. Credential hopping
2. The non-default Administrator account sometimes doesn't have true Administrator access when run through WinRM even with UAC disabled.

In short, this script allows commands to run through WinRM just as if they were run directly on the box.
2014-04-26 21:07:26 -07:00
Shawn Neal cad3dde760 Fixed whitespacing in command_filter and file_manager 2014-04-24 07:52:13 -07:00
Shawn Neal afeb60c850 ivars should be alphabetized 2014-04-24 07:50:24 -07:00
Shawn Neal d5d9918e48 Cleanup whitespace and comments in WinRM command filters 2014-04-24 07:49:19 -07:00
Shawn Neal ab51a786ff Extract execution_output method from WinRM comm execute 2014-04-23 21:49:28 -07:00
Shawn Neal 4a2a147926 Refactored WinRM test command filter 2014-04-23 21:15:05 -07:00
Shawn Neal f44c795eed Integrated WinRM command filter into communicator
*nix commands are now filtered out instead of being sent to the guest. This means the command_alias PowerShell script is no longer needed.

Moved the PowerShell exit code helper to the WinRM shell and changed it to always return an exit code.
2014-04-23 20:38:16 -07:00
Shawn Neal 1525aa0f78 Added WinRM grep command filter
This is needed because isn't available on Windows and Vagrant guest detection attempts to use grep for some OSs.
2014-04-23 20:37:15 -07:00
Shawn Neal ac81841b01 test command should expand environment variables
'$Env:SystemRoot' does not expand
"$Env:SystemRoot" does expand
2014-04-23 18:26:45 -07:00
Shawn Neal 96ab8f60c5 Added WinRM command filters
These will be used to replace the guest side command_alias script that is sent with every communicator execute call. This avoids some uncessary remote calls to the guest, makes it unit testable, and allows larger PowerShell commands to be invoked.
2014-04-23 17:50:20 -07:00
Mitchell Hashimoto eae3f3243e Merge pull request #3517 from mitchellh/communicator-support-for-wql
communicator/winrm: Communicator support for wql
2014-04-23 06:02:24 -07:00
Shawn Neal 5f4a900d8e Add WinRM file transfer error and english text 2014-04-22 14:54:13 -07:00
Shawn Neal f292232ca8 Added Windows guest file manager for recursive uploads
- Since WinRM uploads are so slow, MD5 content checking is used
2014-04-22 14:42:13 -07:00
Shawn Neal 9177bd8a48 Added WQL support to Vagrant communicator execute
- Removed duplication for WQL specific commands
2014-04-22 11:29:22 -07:00
Mitchell Hashimoto db64fbf6ef communicators/winrm: reload shell on reload so we get proper port 2014-04-21 13:56:42 -07:00
Mitchell Hashimoto 6721d8e964 communicators/ssh: just use Ruby 2.0 features 2014-04-21 13:54:52 -07:00
Mitchell Hashimoto bd51c16700 provisioners/puppet: execute properly with WinRM 2014-04-21 13:54:00 -07:00
Mitchell Hashimoto 47b5a3fcdb communicators/winrm: silence warnings loading winrm
/cc @sneal - I silenced warnings using the built-in util. Also, can you
see if we load here if that load error goes away?
2014-04-21 13:51:27 -07:00
Mitchell Hashimoto 7223e29330 communicators/winrm: fix powershell execution 2014-04-21 13:51:05 -07:00
Mitchell Hashimoto 21ac0810fd communicators/winrm: more tests 2014-04-21 13:51:04 -07:00
Mitchell Hashimoto bb9f0aef32 communicators/winrm: autodetect port based on forwarded ports 2014-04-21 13:51:03 -07:00
Mitchell Hashimoto eebebd8837 communicators/winrm: Config unit tests (a little) 2014-04-21 13:50:59 -07:00
Mitchell Hashimoto 2a8a04ebb9 communicators/winrm: initial import from vagrant-windows 2014-04-21 13:50:58 -07:00
Mitchell Hashimoto ad8d133293 communicators/ssh: throttle warnings [GH-3442] 2014-04-11 16:17:17 -07:00
Mitchell Hashimoto 77c92d0d11 communicators/ssh: only show warnings after a few attempts [GH-3442] 2014-04-11 14:36:19 -07:00
Hiroshi Miura a7cc402258 vagrant ssh accept utf8, fix #2744
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
2014-03-30 12:15:53 +09:00
Mitchell Hashimoto f7adeadf8d communicators/ssh: change wording on retry 2014-03-21 17:48:03 -07:00
krazyLee fb4cb4636e fix timout typo 2014-03-11 17:27:47 +08:00
Mitchell Hashimoto c877fc27a7 communicators/ssh: call ready? when waiting
This lets things like the SSH key go in
2014-02-26 11:35:41 -08:00
Mitchell Hashimoto 67a0d3d5f1 communicators/ssh: rescue/show correct error messages 2014-02-23 22:31:37 -08:00
Mitchell Hashimoto 2fe2fe79ed communicators/ssh: properly allow errors through while waiting 2014-02-13 21:04:41 -08:00
Mitchell Hashimoto ed5e544e63 communicators/ssh: more verbose output about waiting for SSH 2014-02-13 20:59:26 -08:00
Mitchell Hashimoto 14b27ae215 communicators/ssh: cache ssh_info
This lowers the number of subprocesses with VirtualBox quite a bit.
2014-02-13 20:34:51 -08:00
Mitchell Hashimoto 3c10bf7721 communicators/ssh: better error message 2014-02-03 12:09:13 +01:00
Justin Campbell a633b7343a Fix wording of upload permission error
SCPPermissionDenied expects a path, and this is most likely the
destination (to) and not source (from).

[#2804]
2014-01-28 13:49:14 -05:00
Mitchell Hashimoto 732a03c1c4 guests/linux: properly quote and insert public key 2014-01-08 15:12:26 -08:00
Mitchell Hashimoto 4c6957b5cf communicators/ssh: if insert_key is false, don't insert a key 2014-01-03 11:29:44 -08:00
Mitchell Hashimoto 54e640b0c9 communicators/ssh: output UI when inserting key 2014-01-03 11:22:05 -08:00
Mitchell Hashimoto b3a9e6a088 insert_public_key cap, and use that if it exists 2014-01-03 11:13:21 -08:00
Mitchell Hashimoto 38e7166a21 communicators/ssh: support passwords 2014-01-03 09:55:34 -08:00
Mitchell Hashimoto 9cd9e6e55d communicators/ssh: add -E to sudo to preserve env 2013-12-03 12:07:14 -08:00
Mitchell Hashimoto 45e09eb677 core: allow multiple private keys [GH-907] 2013-11-25 15:45:39 -08:00
Mitchell Hashimoto 6baab10df4 communicators/ssh: pty can be enabled 2013-11-24 16:48:07 -08:00
Mark Peek d5dcf84d62 Allow the FreeBSD plugin to install without bash [GH-2485]
The default shell is "bash -l" which does not get installed by default
on FreeBSD. This change allows the plugin to override the default shell
and use a known installed shell (sh).
2013-11-22 15:30:12 -08:00
Mitchell Hashimoto f9e4ea9ce8 communicators/ssh: timeout waiting for connection + header [GH-2226] 2013-09-18 09:32:30 -07:00
Mitchell Hashimoto 93f2e9ebbb communicators/ssh: increase conect timeout [GH-2163] 2013-09-15 17:37:40 -07:00
Mitchell Hashimoto 4c35f6d071 core: exec with the proxy command if specified 2013-09-04 17:23:43 -07:00
Mitchell Hashimoto 763bdc42f4 Merge pull request #1537 from wormzer/master
communicator/ssh: Additional proxy_command option
2013-09-04 17:18:59 -07:00
Mitchell Hashimoto a656a99654 communicators/ssh: remove use of nonexistent config 2013-09-02 09:11:39 -07:00
Mitchell Hashimoto 50fdf1358c communicators/ssh: handle closed connection without exception 2013-08-29 10:36:23 -07:00
Mitchell Hashimoto aeb0132dcb Discover and set SSH_AUTH_SOCK on sudo with forward agent [GH-1307] 2013-07-23 17:36:48 -05:00
Mitchell Hashimoto cf1768c7be Retry SSH on ENETUNREACH [GH-1732] 2013-07-20 00:27:25 -04:00
Mitchell Hashimoto 62c1bea7d3 Remote commands show output when fails [GH-1203] 2013-07-17 23:39:42 -04:00
Mitchell Hashimoto 81550392b0 Close SSH channel after exit status received [GH-603] 2013-07-12 06:40:27 +09:00
Emiliano Ticci b0b18c64dd Raise a proper SSH error on EHOSTUNREACH 2013-07-09 14:35:07 +02:00
Mitchell Hashimoto 105bf6129c Improved SSH logging for connections 2013-04-19 10:14:45 -06:00
Neil Wilson f7ce0bc893 Add ssh username to ssh connection log message 2013-04-19 17:03:26 +01:00
Mitchell Hashimoto 8322f20f4b Get rid of arbitrary 4 second sleep for SSH 2013-04-16 13:50:02 -07:00
Mitchell Hashimoto 7fa9892b75 Send SSH keep-alive packets [GH-516] 2013-04-07 21:51:14 -07:00
Matt Wormley 00c9f2c973 added ssh.proxy_command to handle waiting for aws ssh connection when ssh proxy in place. use config.ssh.proxy_command = "ssh -q <user>@<proxy_host> nc %h %p" 2013-04-03 13:54:47 -07:00
Mitchell Hashimoto 8aff752cfb v1.1.6 2013-04-03 08:31:10 -07:00
Mitchell Hashimoto 4f1a3dad8c Retry SSH on Errno::EACCES 2013-03-31 20:27:08 -07:00
Mitchell Hashimoto ed038c8c64 Better detect SSh connections closing 2013-03-28 15:48:36 -07:00
Fabio Rehm 3c4002ac4e Fix typo on ComunicatorSSH plugin name 2013-03-20 11:47:41 -03:00
Mitchell Hashimoto d7b7a32814 Attempt to re-establish SSH connection on Net::SSH::Disconnect 2013-03-18 18:10:54 -07:00
Mitchell Hashimoto c22e4fe19b When there is no route to host for SSH, re-establish a new connection 2013-03-14 12:51:16 -07:00
Mitchell Hashimoto 0b9589a0fa Raise an exception if the provider is reporting SSH is not ready 2013-03-06 14:27:40 -08:00
Mitchell Hashimoto 8c33814397 Retry SSH on EADDRINUSE 2013-02-18 17:14:25 -08:00
Mitchell Hashimoto 4a1a990491 Raise a proper SSH error on ECONNRESET 2013-02-06 18:08:55 -08:00
Mark Peek 5f2c87d41d Allow SSH upload to upload directories 2013-02-05 22:20:19 -08:00
Mitchell Hashimoto 202cfebc24 SSH communicator: check_key_perms should be a Pathname 2013-02-04 21:06:28 -08:00
Mitchell Hashimoto b9fc6068fb Missing requires for SSH 2013-02-04 13:49:03 -08:00
Mitchell Hashimoto 967bd65ac6 Net-SSH logs come out with Vagrant debug logs 2013-02-04 13:46:59 -08:00
Mitchell Hashimoto e3b9ddda1d Specify specific auth methods to use for SSH.
Specifically no "keyboard-interactive" EVER
2013-02-04 13:37:59 -08:00
Mitchell Hashimoto a72cfdbc00 Improved logging and such around SSH 2013-02-04 11:44:56 -08:00
Mitchell Hashimoto 3b75652256 Always log stdout/stderr for SSH 2013-02-01 10:56:00 -08:00
Mitchell Hashimoto b037a8d89c Retry SSH on connection reset 2013-01-31 20:04:57 -08:00
Mitchell Hashimoto c6c27c5e62 Catch Errno::ETIMEDOUT for SSH 2013-01-16 16:42:00 -08:00
Mitchell Hashimoto 22571bf05b Rescue the EHOSTDOWN error for SSH 2013-01-12 12:47:49 -08:00
Mitchell Hashimoto 45f211b19e Communicators to v2 plugins. 2012-11-06 21:14:10 -08:00
Mitchell Hashimoto 544006c16c Whitespace and such 2012-10-12 19:51:25 -07:00
Richard Bullington-McGuire cced762645 Fix Windows shell provisioning
Resolves [GH-1036] [GH-1164] [GH-1181]

Ported fixes from patches to 1-0-stable
2012-10-11 20:33:37 -04:00
Mitchell Hashimoto 5691df37a1 Retry SSH on EHOSTUNREACH
This is one of those errors that happens once in awhile that can be
retried.
2012-08-29 13:39:03 -07:00
Mitchell Hashimoto 0eddda3552 Halt works with new machine.
This required some modifications to the linux guest implementation. And
the other guests will have to be modified as well. This is because
`channel` is now `communicate`.
2012-08-12 18:54:52 -07:00
Mitchell Hashimoto 64afd578b3 Just always return the SSH communicator for machines for now.
In the future we'll actually find a matching communicator but for now
since we're just focusing on machine abstraction, we just return SSH.
2012-08-08 21:57:08 -07:00
Mitchell Hashimoto 595e7cee0e Move SSH communication to a plugin 2012-08-08 21:48:51 -07:00