Commit Graph

46 Commits (d419a13ca75bd7b87ab79b224249c421c5af641f)

Author SHA1 Message Date
Jim Richardson 8d39ae709c sudo -u works now. Needs testing and maybe a bit of cleanup 2012-05-06 18:24:44 -04:00
John Kleint cbbaee8a9f Remove command timeout. 2012-05-02 16:25:04 -04:00
Michael DeHaan 6341361a5b Clarify that stderr WILL crash your module. Can't redirect because if we do we lose tracebacks
from modules remotely when they fail to parse, and this is VERY useful data.
2012-04-27 01:36:31 -04:00
Michael DeHaan 36e454c52f Because paramiko using a pty can't distinguish stderr and stdout, remove handling that
treated -D as a way to show stderr, and make sure modules don't include things on stderr.
Update docs and test module script to come into line.
2012-04-27 01:25:38 -04:00
Michael DeHaan 076f1bc169 Revert "Revert "Unify normal and sudo remote command execution. Breaks stderr/stdout handling"
This reverts commit 40f603539c.
2012-04-27 00:46:26 -04:00
Michael DeHaan 0d5bee2dfa Revert "Revert "Actually wait for password prompt in remote sudo execution. Totally breaks stderr debugging"
This reverts commit e16114034c.

Conflicts:

	lib/ansible/connection.py
2012-04-27 00:46:17 -04:00
Michael DeHaan 40f603539c Revert "Unify normal and sudo remote command execution. Breaks stderr/stdout handling
This reverts commit 44486223ed.
2012-04-27 00:33:48 -04:00
Michael DeHaan e16114034c Revert "Actually wait for password prompt in remote sudo execution. Totally breaks stderr debugging
and various modules.

This reverts commit 6341a9547f.
2012-04-27 00:31:18 -04:00
Michael DeHaan 5aa5a48f7f Merge pull request #250 from jkleint/devel
Service module crashes if args has no "=".
2012-04-26 16:22:56 -07:00
Michael DeHaan a4b3b7a2cf Local connection doesn't need a port. 2012-04-26 19:19:34 -04:00
jkleint 6341a9547f Actually wait for password prompt in remote sudo execution.
When running on lots of hosts with a large login banner on a slow network, it was still possible that the first recv() didn't to pull in the sudo password prompt, and sudo would fail intermittently.  This patch tells sudo to use a specific, randomly-generated prompt and then reads until it finds that prompt (or times out).  Only then is the password sent.  It also catches `socket.timeout` and thunks it to a more useful `AnsbileError` with the output of sudo so if something goes wrong you can see what's up.
2012-04-26 15:01:20 -03:00
cocoy 1220a46e3a Bugfix for issue #245.
Do not override the value of user and hostname.
Get port and identityfile only.
2012-04-26 14:46:32 +08:00
jkleint 44486223ed Unify normal and sudo remote command execution.
Commit SHA: 87b1cf45 that put temp files in `$HOME/.ansible` instead of `/home/<user>/.ansible` was producing a directory literally called `$HOME` (no expansion) with non-sudo remote execution.  I'll take the blame for this one, as `ParamikoConnection.exec_command()` was not using the shell for non-sudo commands.  This does sudo and non-sudo execution the same way, using the shell, so environment variables should get expanded.
2012-04-25 13:40:21 -03:00
Jeroen Hoekx c2f1aefaf1 Expand user in SSH identity file. 2012-04-24 15:56:46 +02:00
Jeroen Hoekx 1804df0bae Whitespace fixes in connection.py 2012-04-24 15:56:04 +02:00
Matt Coddington d34160ed26 cast ssh port number as integer 2012-04-24 00:38:24 -04:00
Michael DeHaan 89c013035e Merge branch 'integration' of https://github.com/cocoy/ansible into cocoy-integration 2012-04-23 21:30:44 -04:00
Michael DeHaan 346df537b4 Merge branch 'integration' of https://github.com/jkleint/ansible into jkleint-integration 2012-04-23 21:21:43 -04:00
Michael DeHaan c00699d0ef Merge branch 'integration'
Conflicts:
	lib/ansible/playbook.py
	lib/ansible/runner.py
	library/apt
2012-04-23 21:05:06 -04:00
jkleint e69e078569 More robust remote sudo.
The basic idea is sudo /bin/sh -c 'quoted_command'.  We use Paramiko's low-level API to set a timeout, get a pseudo tty, execute sudo and the (shell quoted) command atomically, wait just until sudo is ready to accept the password before sending it down the pipe, and then return the command's stdout and stderr.

This should be faster, as there are no unneeded sleeps.  There are no permissions issues reading the output.  It will raise socket.timeout if the command takes too long.  However, this is a per-read timeout, not a total execution timeout, so as long as the command is writing output and you are reading it, it will not time out.

Local and non-sudo commands remain unchanged, but should probably adopt a similar approach.

Since this is a significant change, it needs a lot of testing.  Also, someone smarter than I should double-check the quoting and execution, since it is a security issue.
2012-04-23 17:32:08 -03:00
cocoy c844a2d072 Fix to skip /.ssh/config if don't exist rather than raise an error. 2012-04-23 14:32:57 +08:00
cocoy 645b7a2dff Add .ssh/config support 2012-04-23 09:48:42 +08:00
Michael DeHaan 08468dcb0c Fixes to make ports DWIM. 2012-04-16 21:52:15 -04:00
Rafal Lewczuk a87c77958c clean exec bits from lib/ansible/*.py, ignore Eclipse/PyDev files 2012-04-14 21:35:51 +02:00
Michael DeHaan f2465e0571 Add support for specifying sudo passwords to both ansible & playbook. Nopasswd sudo is no longer required. 2012-04-13 19:06:11 -04:00
Stephen Fromm 0675f2511b Merge branch 'master' into localconnection
Merge the SortedOptParser bits and debug attribute commits into
localconnection.

Conflicts:
	bin/ansible
	lib/ansible/playbook.py
	lib/ansible/runner.py
	lib/ansible/utils.py
2012-04-12 11:18:35 -07:00
Michael DeHaan a0480a1bc5 Block some paramiko warnings that are not relevant. 2012-04-11 20:20:55 -04:00
Matthew Williams 611e3fec4c fetch 'module' -- working with paramiko and local connections 2012-04-10 20:23:25 -07:00
Stephen Fromm 9213cf896e Change to transport is local *and* is localhost
Connection.connect() now requires that, in order to use LocalConnection,
you specify transport is local and that the hostname is localhost.
2012-04-10 13:20:03 -07:00
Michael DeHaan 6749903e57 Allow explicit request of the local connection. 2012-04-07 14:51:00 -04:00
Stephen Fromm 70a3fab79f Add LocalConnection class to connection.py
This creates a LocalConnection class for the case when operating on the
localhost.  If the host, argument to Connection.connect(), matches
127.0.0.1, localhost, or the name of the host as returned by
os.uname()[1], Connection.connect() will opt to use LocalConnection
instead of ParamikoConnection.  LocalConnection implements connect(),
exec_command(), put_file(), and close().
2012-04-06 16:38:27 -07:00
Michael DeHaan 6275e57718 pyflakes: Unused import / unused var 2012-03-30 23:04:02 -04:00
Michael DeHaan 2372a3b734 Sudo support operational in both playbooks and main program. Implementation could use some cleanup. 2012-03-29 22:59:29 -04:00
Michael DeHaan 81e3496037 Added preliminary support for --sudo to ansible, playbook support and further testing pending. 2012-03-29 01:37:06 -04:00
Michael DeHaan 72cc99722d sudo tweaks 2012-03-28 23:30:31 -04:00
Michael DeHaan c2a6e2f97b Work in progress on sudo, hitting some issues with paramiko saying the connection is closed. 2012-03-28 22:51:16 -04:00
Michael DeHaan 7133734d87 Remove debug statements (WIP on sudo) 2012-03-28 20:58:34 -04:00
Michael DeHaan 706ba9fd9a Add paramiko/pycrypto atfork workaround (can back out later if not useful), tweak error
message text per skvidal's suggestion
2012-03-28 20:32:04 -04:00
Christopher Johnston 15e781eb51 add exception check for paramiko if older then 1.7 2012-03-28 14:09:11 -07:00
Christopher Johnston f06ec76fdb add support for using an alternate remote port 2012-03-28 14:05:31 -07:00
Seth Vidal 89d4bc542c fix up minor type - AnsibleException should be AnsibleError 2012-03-23 11:59:08 -04:00
Michael DeHaan c861e0de55 Fix "import *" and resultant new things detectable from "make pyflakes" 2012-03-18 17:16:12 -04:00
Michael DeHaan 24923c2e17 Purge unused imports per pyflakes 2012-03-15 23:06:59 -04:00
Michael DeHaan 4ae98ed92d Upgrades to error handling, now general try/catch available. 2012-03-13 20:59:05 -04:00
Michael DeHaan 86e19cd8c8 This adds async poll support to playbooks. See examples. Some more testing due + docs
but this is more or less a mirror of what /bin/ansible does.  It also has a 'fire and
forget' mode if the poll interval is left off or set to 0.
2012-03-12 20:53:10 -04:00
Michael DeHaan bb5e4fad48 Abstracted out transport from implementation so it can be pluggable. Also fixes for output format. 2012-03-10 13:35:46 -05:00