Commit graph

307 commits

Author SHA1 Message Date
Reed Murphy
abf524405a shlex.split() tries to read from stdin if passed None 2012-04-27 11:25:43 +10:00
Michael DeHaan
b9982fc17b Reinstate --extra-vars, which can do things in playbooks like:
ansible-playbook release-my-app.yml --extra-vars="version=123"

And make $version available in the playbook without re-editing the file
2012-04-26 19:57:07 -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
Seth Vidal
fa2aebc8a6 fix for issue #230 - handle template taking 3 args 2012-04-25 11:59:19 -04:00
Michael DeHaan
87b1cf45a4 Merge pull request #226 from cread/make-osx-tests-pass
Use the $HOME env var instead of hard coding /home/<username>
2012-04-24 15:22:43 -07:00
jkleint
4e1bc43645 Support YAML lists of hosts in playbooks.
Reading the docs, I was a bit confused as to how to specify multiple hosts/groups in a playbook.  Being YAML, I assumed a normal YAML list would work:

    ---
    - hosts: [host1, host2]

But this crashes when inventory._matches() assumes hosts is a string.  This patch just checks if hosts is a list, and turns it into a string joined by ';'.
2012-04-24 17:54:00 -03:00
Chris Read
dbb4afff50 Use the /Users/cread env var instead of hard coding /home/<username> 2012-04-24 21:45:54 +01:00
jkleint
b50c50748e _chain_file_module() calls .get() on error string
runner._return_from_module() normally returns a list (?) of `[str,bool,dict,str]`, but on error it returns `[str,bool,str,str]`.  runner._chain_file_module() then tries to call .get() on the third item (`data2`), which fails when it's a string.  This patch only accesses `data2` if the return value was `ok`.  It might be better to return consistent types in both cases, but I'm not sure where/how else the return value is used.
2012-04-24 17:21:01 -03:00
Seth Vidal
41619278e5 handle issues when the hostlist is inadvertently set executable
and/or executing it fails. This produces a nicer error message than
a traceback
2012-04-24 11:03:14 -04:00
Michael DeHaan
02abb5a83b Merge pull request #217 from jhoekx/connection-fixes
Expand user in ssh identity file
2012-04-24 07:40:33 -07:00
Jeroen Hoekx
973b1fe02e Fix incorrect merge of custom-facts branch.
This fixes #216.
2012-04-24 16:11:56 +02: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
bced4c9db1 Merge branch 'jhoekx-custom-facts' into devel 2012-04-23 21:25:26 -04:00
Michael DeHaan
49cca98f1e Merge branch 'custom-facts' of https://github.com/jhoekx/ansible into jhoekx-custom-facts
Conflicts:
	lib/ansible/runner.py
2012-04-23 21:24:52 -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
7de90c4e64 Version bump for integration branch (soon to be renamed 'devel'), didn't update package
changelogs yet since this isn't released yet (but 0.3 is)
2012-04-23 21:14:48 -04:00
Michael DeHaan
4d62510997 Version bump for 0.3 release 2012-04-23 21:11:43 -04:00
Michael DeHaan
a8707e48e8 Fix merge issue 2012-04-23 21:06:47 -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
Michael DeHaan
321ed53e3a Fetch module doesn't set invocation parameter as it invokes nothing, so don't let that be an error. 2012-04-23 21:02:39 -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
Jeroen Hoekx
2dc9a563ef Allow modules to return facts.
If the module result contains "ansible_facts", that will be added to the setup
cache.
2012-04-23 21:28:12 +02: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
533c2c6126 Make it possible to use facts from hosts in templates for other hosts.
It works like this:

{{ hostvars['127.0.0.1']['ansible_eth0']['ipv4']['address'] }}
2012-04-21 12:45:37 -04:00
Michael DeHaan
767282df2a Small style fixes for indentation and spacing. 2012-04-21 12:06:54 -04:00
Michael DeHaan
bed5da6086 Remove unused assignment 2012-04-21 12:03:29 -04:00
Michael DeHaan
ddc0342920 Unused import 2012-04-21 12:01:37 -04:00
Michael DeHaan
1e7b60b9a5 Unused import 2012-04-21 12:01:26 -04:00
Michael DeHaan
9d0f2a6e9b Unused import 2012-04-21 12:01:15 -04:00
Michael DeHaan
3081bb93f1 Use /var/tmp for root by default to avoid /tmp being mounted noexec, and segregate tmp files for other users
into their home directories.
2012-04-21 11:38:39 -04:00
Michael DeHaan
3d72260887 Make it such that modules with no arguments work fine in playbooks (like ping, which is
non-sensical, but also if the user wrote a module that took none)
2012-04-21 11:26:48 -04:00
Michael DeHaan
c6b8e1621d A better fix for slurp, expand path in the module. 2012-04-20 07:54:38 -04:00
Michael DeHaan
13ba31231e Fixup slurp module usage when not running as root, fix error handling path in slurp module. 2012-04-19 11:38:44 -04:00
Michael DeHaan
8a433ecb96 Merge branch 'align-vars-syntax' of https://github.com/jhoekx/ansible into jhoekx-align-vars-syntax 2012-04-19 09:15:48 -04:00
Jeroen Hoekx
cdb8213dcc Supported 'listed' vars in playbooks. 2012-04-19 09:40:17 +02:00
Jeroen Hoekx
903e4f6eae Support dicts in inventory vars. 2012-04-19 09:40:17 +02:00
Michael DeHaan
9cd492befe make all templating happen locally, so no jinja2 deps are ever required 2012-04-18 22:43:17 -04:00
Michael DeHaan
30d06dbcea Don't force down ansible facts back to setup, the setup module won't like parsing them on input and that
data is already there.
2012-04-18 22:23:33 -04:00
Michael DeHaan
5fa3d9b148 Teach playbooks to template locally to eliminate the need for Jinja2 on remote nodes.
You still need jinja2 if using /usr/bin/ansible vs /usr/bin/ansible-playbook though
this could change later by fetching the ansible file with a 'slurp' module.
2012-04-18 22:19:25 -04:00
Michael DeHaan
da0209dbc4 The fetch module really should preserve the whole directory structure being fetched to allow subsequent calls,
particularly in playbook, to recreate the host tree structure.  Making it thus.
2012-04-18 21:12:48 -04:00
Jeroen Hoekx
22ff8282a8 Template template module source. 2012-04-18 14:26:33 +02:00
Jeroen Hoekx
b678cf783c Template the source file of the copy module. 2012-04-18 11:40:15 +02:00