summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/connection/ssh.py
Commit message (Collapse)AuthorAgeFilesLines
* Ignores ControlPersist broken pipe errors. Fixes #16731Strahinja Kustudić2017-04-071-5/+21
| | | | | | | | | Ansible will now automatically retry a connection if SSH returns an error: mux_client_hello_exchange: write packet: Broken pipe This is probably a bug in SSH, but because it's safe to retry this connection there is no need for Ansible to fail because of it.
* Update module_utils.six to latest (#22855)Toshio Kuratomi2017-03-231-3/+4
| | | | | | | | * Update module_utils.six to latest We've been held back on the version of six we could use on the module side to 1.4.x because of python-2.4 compatibility. Now that our minimum is Python-2.6, we can update to the latest version of six in module_utils and get rid of the second copy in lib/ansible/compat.
* uncommit the crime of extra spaces in docstringBrian Coca2017-03-231-1/+1
|
* Enable documentation in pluginsBrian Coca2017-03-231-0/+78
| | | | | | | | | | | | | Made ansible-doc more plugin agnostic We can have docs in lookup, callback, connectionm strategy, etc Use first docstring and make pepizis happy generalized module_docs to plugin_docs documented cartesian, ssh, default, jsonfile, etc as examples changed lack of docs to warning when listing made smarter about bad docstrings better blacklisting added handling of options/config/envs/etc move blacklist to find_plugins, only need once
* E501 fixes (#22879)Matt Martz2017-03-221-2/+4
|
* Extend SSH Retry to put_file and fetch_file (#20187)Matt Martz2017-03-021-71/+79
| | | | | | | | | | | | * Move retry logic into _ssh_retry decorator, and apply to exec_command, put_file and fetch_file * Update tests to reflect change * Move _ssh_retry to _run, and update tests to reflect * piped should use exec_command instead of removed _exec_command * Rework tests to support selectors instead of select.select
* tweak transport_tests to avoid logic duplication (#22158)Matt Davis2017-03-011-3/+4
|
* wait_for_connection: Wait for system to become reachable (#20011)Dag Wieers2017-03-011-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * WIP: wait_for_connection: Wait for system to be reachable This action plugin allows to check when a system is back online and usable by Ansible. As an example, when doing a SysPrep and running Enable-WinRM.ps1, it takes between 10 to 20 seconds between the WinRM TCP port to open, and it actually being able to server Ansible requests. This time is variable and depends on the boot process. Current implementation is specific for Windows (WinRM) only, this will be fixed shortly. This fixes #19998 * Support other transport types * Various improvements - Fix reported typo - Add transport_test support in accelerate plugin - Ensure port is an integer * Improve examples * Small fixes - Use correct ConfigureRemotingForAnsible.ps1 script name - Only use win_ping when remote shell is known to be Powershell - Add integration tests to CI framework
* PEP8 E712 fixes (#21916)Matt Martz2017-02-241-1/+1
|
* the return of reset_connectionBrian Coca2017-02-161-13/+11
| | | | | | allows user to force persistent connection to close, needed for when you want to benefit from changes applied to the current play but persistent connections prevent them from being realized.
* Move ssh and local connection plugins from using raw select to selectorsToshio Kuratomi2017-02-031-129/+140
| | | | | | | | | | | | | | | At the moment, this change will use EPoll on Linux, KQueue on *BSDs, etc, so it should alleviate problems with too many open file descriptors. * Bundle a copy of selectors2 so that we have the selectors API everywhere. * Add licensing information to selectors2 file so it's clear what the licensing terms and conditions are. * Exclude the bundled copy of selectors2 from our boilerplate code-smell test * Rewrite ssh_run tests to attempt to work around problem with mocking select on shippable Fixes #14143
* Do not substitute ssh_exeuctable until we need toToshio Kuratomi2017-02-021-7/+7
| | | | | | | | | We need to use ssh_executable instead of hardcoding ssh in the command we run but we need to use "ssh" when we lookup the value of the {command}_extra_args variable. Do this by leaving binary as "ssh" and only expanding when we place it into b_command. Fixes #20862
* Use a -short- custom hash for controlpersist path by default (#20843)jctanner2017-02-011-2/+23
| | | | | | | | | | | | | * A method to validate and alter the ssh control path automatically. * First tries %C to use the shortened hash * On further failure, it removes section by section from the original path * Fix hostname * Implement bcoca's suggested changes * Remove unused option * Remove unused class var * Use to_string to avoid unicode error * Switch from to_text to to_bytes * Update the example config for the new controlpath feature
* Show remote host in error message. (#20823)Dag Wieers2017-01-301-2/+2
| | | | | | * Show remote host in error message. * Typos :-/
* PEP 8 indent cleanup. (#20800)Matt Clay2017-01-291-2/+2
| | | | | | | | * PEP 8 E121 cleanup. * PEP 8 E126 cleanup. * PEP 8 E122 cleanup.
* Add pipeline-ish method using dd for file transfer over SSH (#18642)Andrew Gaffney2017-01-191-19/+45
|
* include source file in error messageBrian Coca2017-01-181-2/+2
|
* Fix fetching files with scp (#18673)Alberto Murillo2016-11-301-1/+1
| | | | | | | | | Commit ec2521f intended to fix the scp command to fetch files from a remote machine but it has src and dest swapped. This change correctly treats src as the location in the remote machine and dest as the location in the local machine. Signed-off-by: Alberto Murillo Silva <alberto.murillo.silva@intel.com>
* unified boolean functionBrian Coca2016-11-291-1/+1
| | | | | optimized boolean function fixes #17815
* Fix ssh plugin to correctly fetch files when using scp (#18614)Alberto Murillo2016-11-261-1/+4
| | | | | | | | | | | | | | | | | | Fetch module uses fetch_file() from plugin/connection/ssh.py to retrieve files from the remote hosts which in turns uses _file_transport_command(self, in_path, out_path, sftp_action) being sftp_action = 'get' When using scp rather than sftp, sftp_action variable is not used and the scp command is formed in a way that the file is always sent to the remote machine This patch fixes _file_transport_command() to correctly form the scp swaping src and dest if sftp_action is 'get' Bug introduced at 8e47b9b Fixes #18603 Signed-off-by: Alberto Murillo Silva <alberto.murillo.silva@intel.com>
* Mcsalgado's change to use shlex.quote instead of pipes.quote (#18534)Toshio Kuratomi2016-11-171-4/+4
| | | | | | | | | | | | | | | | * Replace pipes.quote for shlex_quote * More migration of pipes.quote to shlex_quote Note that we cannot yet move module code over. Modules have six-1.4 bundled which does not have shlex_quote. This shouldn't be a problem as the function is still importable from pipes.quote. It's just that this has become an implementation detail that makes us want to import from shlex instead. Once we get rid of the python2.4 dependency we can update to a newer version of bundled six module-side and then we're free to use shlex_quote everywhere.
* ANSIBLE_SSH_CONTROL_PATH_DIR option added (#18342)Andrea Tartaglia2016-11-031-1/+1
| | | | | | | | | | | * ANSIBLE_SSH_CONTROL_PATH_DIR option added This removes the hardcoded value ( $HOME/.ansible/cp ) from ssh.py. User is able to change the ControlPath directory ( the one that replaces %(directory)s ). Fixes #18325 * Added config option in ansible.cfg
* Fix OpenSSH-related ssh process exit racejasdeep-hundal2016-10-271-12/+13
| | | | | | | Mitigate the effects of observing the ssh process still running after seeing an EOF on stdout when using OpenSSH with ControlPersist, since it does not close the stderr file descriptor in this case.
* Handle 'smart' scp_if_ssh option for fetch (#18125)Ssawa2016-10-211-64/+51
|
* On python3, subprocess needs another arg to pass extra file descriptorsToshio Kuratomi2016-10-021-3/+9
|
* Normalize text and byte type in the ssh plugin helper method that builds up ↵Toshio Kuratomi2016-10-021-57/+68
| | | | | | an ssh command (#17860) Mostly cleanups to make the code more efficient, more pythonic, and obey the unicode sandwich strategy more but also Fixes #17832
* add ssh error message to failureBrian Coca2016-09-301-4/+1
|
* Smart mode for sftp+scp (#17813)jctanner2016-09-291-14/+49
| | | | | | | If the sftp fails, roll over to scp by default. This saves users from having to know about the scp_if_ssh method when sftp is broken on the remote host.
* Make ssh_executable available as ansible_ssh_* variable (#17450)Andrea Tartaglia2016-09-071-3/+4
|
* Added option to change ssh executable path (#17377)Andrea Tartaglia2016-09-071-4/+7
|
* Move uses of to_bytes, to_text, to_native to use the module_utils version ↵Toshio Kuratomi2016-09-061-12/+12
| | | | | | | | (#17423) We couldn't copy to_unicode, to_bytes, to_str into module_utils because of licensing. So once created it we had two sets of functions that did the same things but had different implementations. To remedy that, this change removes the ansible.utils.unicode versions of those functions.
* Get the ssh plugin working with python3 (#17234)Toshio Kuratomi2016-08-251-55/+56
|
* Ignore broken pipe errors if the sshpass process has exited (#16515)graywulf2016-06-301-1/+7
| | | | | This fix prevents a broken pipe exception from occurring when password-less SSH is configured and the sshpass process exits and closes the pipe before the password is written to the pipe.
* made ssh compression configurable (#16214)Brian Coca2016-06-101-2/+0
| | | | | AIX ssh does not seem to like compression, moved it to ssh_args to allow making it configurable. Note that those using ssh_args already will need to add it explicitly to keep compression.
* Disable sftp batch mode if sshpass (#15829)jctanner2016-05-131-1/+5
| | | | | Make use of the -oBatchMode=no option to force password prompts from sftp Addresses #13401
* Don't use -tt for ssh connections when sudoable=FalseJames Cammarata2016-04-111-3/+4
| | | | | | | | | | | Due to an apparent race condition while using pty's on a heavily loaded system, rarely a request to create a temp directory returns an empty string rather than the newly created path, causing an error. Disabling forced pty's appears to resolve the issue, so this patch modifies the mkdtemp remote call not use -tt as we're not escalating privileges and thus no pty is required. Fixes #13876
* Fix inconsistent/missing host names in messages.Matt Clay2016-03-251-1/+1
|
* Fix ssh connection plugin to work with python3Toshio Kuratomi2016-03-091-2/+2
|
* Fixing minor logic error in error detection/handling in ssh connection pluginJames Cammarata2016-03-081-1/+1
| | | | | If max retries were reached, no AnsibleConnectionFailure was raised, which means potentially in some cases an unreachable error might not be returned
* Use to_bytes on filenames in filesystem calls.Matt Clay2016-03-041-1/+1
|
* Merge pull request #13654 from sivel/paramiko-proxy-commandMatt Martz2016-02-231-12/+2
|\ | | | | Add ProxyCommand support to the paramiko connection plugin
| * Move _split_args from ssh.py to ConnectionBase so we can use it in other ↵Matt Martz2015-12-241-12/+2
| | | | | | | | connection plugins
* | More fixes for unicode handling in the connection plugins.Toshio Kuratomi2016-01-061-15/+17
| | | | | | | | | | Tested that ssh, docker, local, lxc-libvirt, chroot all work with the updated unicode integration test.
* | Fix problems with non-ascii values passed as part of the command to ↵connection-plugins-unicode-fixToshio Kuratomi2016-01-041-4/+13
|/ | | | | | | connection plugins @drybjed discovered this with non-ascii environment variables and command line arguments to script and raw module.
* Revert "Enable host_key checking at the strategy level"James Cammarata2015-12-171-182/+11
| | | | This reverts commit 1a6d660d7e285cceec474952a33af4d8dffd0a8d.
* Revert "Fixing bugs in ssh known_host fetching"James Cammarata2015-12-171-21/+8
| | | | This reverts commit 21c127c5813c800204c729d84188f1e6d7bae3e7.
* Fixing bugs in ssh known_host fetchingJames Cammarata2015-12-171-8/+21
| | | | | | | * If remote_addr is not set in the PlayContext, use the host.address field instead (which is how the action plugin works) Fixes #13581
* Enable host_key checking at the strategy levelJames Cammarata2015-12-161-11/+182
| | | | | Implements a new method in the ssh connection plugin (fetch_and_store_key) which is used to prefetch the key using ssh-keyscan.
* Clean up debug logging around _low_level_execute_commandAbhijit Menon-Sen2015-12-111-1/+1
| | | | | | | | | | We were logging the command to be executed many times, which made debug logs very hard to read. Now we do it only once. Also makes the logged ssh command line cut-and-paste-able (the lack of which has confused a number of people by now; the problem being that we pass the command as a single argument to execve(), so it doesn't need an extra level of quoting as it does when you try to run it by hand).
* become_pass needs to be bytes when it is passed to ssh.Toshio Kuratomi2015-12-101-1/+1
| | | | Fixes #13240