Commit graph

7454 commits

Author SHA1 Message Date
Junegunn Choi
daf797804b Allows whitespaces around assignment operators
when defining group variables
2012-12-14 20:43:29 +09:00
fdavis
7347e54b70 change error message on check_conditional when variable does not exist 2012-12-13 23:02:30 -08:00
Stephen Fromm
ccca5fcd1c Ensure files created by authorized_key have correct selinux context
Three changes:
* Add set_default_selinux_context() to module_common that sets
  a file's context according to the defaults in the policy
* In atomic_replace(), set the default context for the file if
  selinux is enabled and the destination file does not exist.
* In authorized_key, set the default context when creating
  $HOME/.ssh and $HOME/.ssh/authorized_keys.  If these already
  exist, this won't touch them.
2012-12-13 16:35:49 -08:00
Dag Wieers
cd930d2e34 Change message when a play matches no hosts
I guess my previous pull request was confusing, by changing the message to something we already do for tasks, it makes it more clear.

Just like we say:

    TASK: [foo bar]
    skipping: [system01]

The message now is more clear:

    PLAY [wagawaga] *******************************
    skipping: no hosts matched

It makes it clear that we are skipping the play, just as is done for a task when a condition is not met.
2012-12-13 13:31:41 +01:00
Michael DeHaan
70bb7d1e54 Merge pull request #1696 from gregorg/enhance_limit
Allow regex to be used to select hosts in addition to fnmatch pattern
2012-12-12 14:51:44 -08:00
Daniel Hokka Zakrisson
54b45e9bd4 Allow intersecting host patterns by using &
This allows patterns such as webservers:!debian:&datacenter1 to target
hosts in the webservers group, that are not in the debian group, but are
in the datacenter1 group. It also parses patterns left to right.
2012-12-12 11:36:12 +01:00
Norman J. Harman Jr
6603737e4d Alphabetic inventory hostname patterns.
- Code, docs, tests.
  - Also added test of large range 000-142 to verify alpha range did not
    break this.
2012-12-10 20:48:38 -06:00
Dag Wieers
dd4ac46397 Import errno to avoid 'NameError: global name 'errno' is not defined'
I hit the following exception because errno is referenced but not imported.

```
fatal: [system01] => failed to parse: Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-1354644532.37-246102819320352/copy", line 782, in <module>
    main()
  File "/root/.ansible/tmp/ansible-1354644532.37-246102819320352/copy", line 117, in main
    module.atomic_replace(dest_tmp, dest)
  File "/root/.ansible/tmp/ansible-1354644532.37-246102819320352/copy", line 772, in atomic_replace
    if e.errno != errno.EPERM:
NameError: global name 'errno' is not defined
```
2012-12-04 19:27:22 +01:00
Michael DeHaan
dbf5a57a5a Merge pull request #1683 from bcoca/template_override
Template override
2012-12-02 10:15:10 -08:00
Daniel Hokka Zakrisson
e54b4b1c9a Ignore arguments when checking for interpreter, and re-add before use 2012-12-02 14:28:52 +01:00
Daniel Hokka Zakrisson
d5a456fbcf Merge pull request #1697 from bcoca/mint
Implements multiple interpreter overrides
2012-12-02 05:28:28 -08:00
Daniel Hokka Zakrisson
ffac7ce2f9 Merge pull request #1687 from dhozac/allow-grouping-in-external-inventory
Allow inventory scripts to define groups of groups and group vars
2012-12-02 05:26:54 -08:00
Dag Wieers
c65c00cb34 Updated ansible version to align with RPM package 2012-12-01 16:37:10 +01:00
Michael DeHaan
5890a2a9da Release stuff 2012-11-30 22:06:25 -05:00
Michael DeHaan
9afb7c1ed0 Get ready to release 0.9 2012-11-30 22:03:31 -05:00
Jan-Piet Mens
17f31a2a79 CLI: ansible-doc shows lists of modules & module docs on command-line
check path is directory
added manpage & setup
small cleanup
shut up module_formatter in utils to avoid trace print on crud files in library
2012-11-30 21:57:25 -05:00
Daniel Hokka Zakrisson
8d309e0fa3 Allow inventory scripts to define groups of groups and group vars 2012-11-28 23:37:29 +01:00
Daniel Hokka Zakrisson
b8d6dec5ad Reset notified_by list per serialized batch
Fixes the case where a handler attempts to run for every batch after any
batch has notified it, regardless of whether the current batch did.
2012-11-28 22:04:44 +01:00
Daniel Hokka Zakrisson
a56e1f31fa Properly restrict hosts after 9070875 2012-11-28 22:03:23 +01:00
Daniel Hokka Zakrisson
f6245e17c1 Skip evaluating only_if for BYPASS_HOST_LOOP plugins 2012-11-28 21:37:30 +01:00
Daniel Hokka Zakrisson
bda08c8a1b Avoid creating temporary directory for some action plugins
This ensures we don't litter remote systems with temporary directories
that don't get cleaned up, as well as speeds things up from not having
to touch every node.
2012-11-28 21:34:55 +01:00
Daniel Hokka Zakrisson
f6e7381a71 Evaluate only_if in group_by 2012-11-28 16:22:58 +01:00
Daniel Hokka Zakrisson
9070875a6f Move available hosts gathering to a common function 2012-11-28 01:03:18 +01:00
Daniel Hokka Zakrisson
5065103017 Skip already failed hosts
Fixes #1699.
2012-11-28 00:54:08 +01:00
Daniel Hokka Zakrisson
c948c65bcd Template the name of the task
Broken by 1e0295c. Fixes #1698.
2012-11-28 00:36:10 +01:00
Brian Coca
2f2bd87b06 multiple _interpreter overrides with ansible_<bin>_interpreter variables, not
just for python anymore
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2012-11-27 11:18:57 -05:00
Gregory Duchatelet
dde01dabc3 Squashed commit of the following:
commit 48069adf0f
Author: Gregory Duchatelet <skygreg@gmail.com>
Date:   Tue Nov 27 10:13:08 2012 +0100

    Removing this plugin from this branch.

commit 15400fffe6
Author: Gregory Duchatelet <skygreg@gmail.com>
Date:   Tue Nov 27 09:53:16 2012 +0100

    Enhance _match function in inventory with regex.
    --limit ~regex could be used to filter hosts or group with a regex.
    Tested on cli and ansible-playbook.

commit 63c1b2e17e
Author: Gregory Duchatelet <skygreg@gmail.com>
Date:   Tue Nov 27 09:03:41 2012 +0100

    Revert pull request #1684

commit 7c2c6fee3a
Merge: f023a2f dd5a847
Author: Gregory Duchatelet <skygreg@gmail.com>
Date:   Tue Nov 27 08:52:53 2012 +0100

    Merge remote branch 'upstream/devel' into devel

commit f023a2f3df
Author: Gregory Duchatelet <skygreg@gmail.com>
Date:   Mon Nov 26 20:52:27 2012 +0100

    Add an inventory plugin to fetch groups and host from our CMDB.

commit c64193b4c6
Author: Gregory Duchatelet <skygreg@gmail.com>
Date:   Mon Nov 26 20:43:30 2012 +0100

    Added possibility to filter hosts from a group, with a regex, separating
    groupname and regex with a ~
    Usage in group pattern: group~filterpattern
    Samples:
    ansible group~server-0[1236] -m ping
    ansible web~proxy -m ping
    ansible web~(proxy|frontend) -m ping
2012-11-27 16:36:58 +01:00
Daniel Hokka Zakrisson
900790af41 Reuse inventory object created by ansible-playbook in playbook
This reduces the amount of times an inventory script has to be invoked.
2012-11-27 15:24:33 +01:00
Daniel Hokka Zakrisson
d703f92077 Disable authentication methods that weren't specified 2012-11-27 15:24:33 +01:00
Stephen Fromm
6a68d3813f Set LANG in module_common.py
Add constant DEFAULT_MODULE_LANG that defaults to C.  Can be set via
environment variable ANSIBLE_MODULE_LANG or configuration variable
module_lang.  Updated test-module to have same behavior.
2012-11-27 00:16:06 -08:00
Michael DeHaan
da90c5f75e Document 'when' and tweak the code to be a little more comprehensive on what is false. 2012-11-26 18:37:44 -05:00
Daniel Hokka Zakrisson
43bdec8b20 Throw an error if multiple actions have been specified 2012-11-26 22:42:44 +01:00
Daniel Hokka Zakrisson
1e0295c7e2 Template handlers late
This allows overriding variables in name, and removes templating from
parsing.
2012-11-26 22:07:57 +01:00
Daniel Hokka Zakrisson
ebd31af940 Don't prompt for vars in extra-vars
Fixes #1622.
2012-11-26 22:07:57 +01:00
Daniel Hokka Zakrisson
94fc3006e9 Make variables local to the play
Fixes #1677.
2012-11-26 22:07:57 +01:00
Brian Coca
d7f38d07b3 fixed bug for string size mismatch, now substring depends on size of match string Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2012-11-26 10:41:13 -05:00
Brian Coca
6a1e2aaff5 moved override matching string to variable changed test template to match Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2012-11-26 10:41:13 -05:00
Brian Coca
68f5d69365 added ability to override jinja enviornment from first line of template Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2012-11-26 10:41:13 -05:00
Daniel Hokka Zakrisson
0c70abfaa9 Make sure any existing groups gets reused 2012-11-25 12:42:30 +01:00
Daniel Hokka Zakrisson
5504f13c68 Create groups in the first run through the file
Fixes #1208.
2012-11-25 01:00:14 +01:00
Daniel Hokka Zakrisson
2bfb7deec0 Set all in the returned dict
Otherwise the group is lost, and group_vars/all isn't used.
2012-11-25 00:15:22 +01:00
Michael DeHaan
33196ec131 Merge pull request #1669 from dagwieers/ssh-tcgetattr2
Use proper pseudo-tty's instead of pipes when using subprocess
2012-11-24 08:30:26 -08:00
Dag Wieers
7192eb3047 Use proper pseudo-tty's instead of pipes when using subprocess
This change avoids the "tcgetattr: Invalid argument" error by making sure the ssh we start does have a proper pseudo-tty.

We could also check whether our current terminal is a proper terminal (by doing a tcgetattr ourselves) but I don't think this adds anything.

This closes #1662 (if all use-cases have been tested: sudo, passwd)
2012-11-23 22:39:30 +01:00
Daniel Hokka Zakrisson
db1a65342a Set -c local cwd to . if basedir is empty 2012-11-23 13:36:09 +01:00
Daniel Hokka Zakrisson
715d875dcb Group should only return its own variables
Otherwise, a host in two groups, A and B, using a variable defined
in group A and all will get the value of all, as B's variables will
include the all variable.

Partially fixes #1647.
2012-11-23 00:54:07 +01:00
Daniel Hokka Zakrisson
e44b85daba Remove special-casing for all group
global_vars has higher precedence than inventory. Putting the all
group's variables into it overrides all other groups and hosts.

Partially fixes #1647.
2012-11-23 00:54:02 +01:00
Daniel Hokka Zakrisson
bd7e02d629 Get all groups' variables in order of depth
Fixes all not being processed, as well as the order of the variable
precedence
2012-11-23 00:20:52 +01:00
Daniel Hokka Zakrisson
d5dd89a8f7 Allow specifying when: ... 2012-11-22 23:11:42 +01:00
Daniel Hokka Zakrisson
fd732f8d3b Add when_boolean
Fixes #1567.
2012-11-22 23:10:11 +01:00
Daniel Hokka Zakrisson
ddef608c94 Wrap all remote commands in sh 2012-11-22 20:06:30 +01:00
Daniel Hokka Zakrisson
047d089cea Restore git output on --version
Broken by the move from utils.py to utils/__init__.py
2012-11-21 23:54:42 +01:00
Daniel Hokka Zakrisson
ef357ed1f2 Use the play's vars for the setup step
Allows using -e ansible_ssh_port=foo and have it apply to all actions.
2012-11-21 23:42:24 +01:00
Daniel Hokka Zakrisson
d1c285b70b Port may be an integer when parsed from the play 2012-11-21 17:20:03 +01:00
Michael DeHaan
82f4aef959 Merge pull request #1648 from dhozac/local-cwd-basedir
Use runner's basedir as cwd for -c local
2012-11-21 06:40:01 -08:00
Michael DeHaan
41af2fce64 Merge pull request #1650 from dagwieers/port-not-integer-exception
Provide a proper error when the remote_port is not an integer
2012-11-21 06:39:24 -08:00
Daniel Hokka Zakrisson
3ce63d845e remote_port is None by default 2012-11-21 14:10:10 +01:00
Daniel Hokka Zakrisson
6b69b37eb0 Merge pull request #1649 from dagwieers/template-port
Allow the remote port to be templated per play
2012-11-20 13:16:34 -08:00
Dag Wieers
85bba04a1c Provide a proper error when the provided port is not an integer
As reported on the mailinglist, the user received a ValueError when the port number was not templated (fixed in #1649) and therefore it was not an integer. This change will catch the exception and provide a proper error so it is more clear.
2012-11-20 19:06:27 +01:00
Dag Wieers
8458f53014 Allow the remote port to be templated
This was requested on the mailinglist and seems useful.
2012-11-20 18:53:40 +01:00
Daniel Hokka Zakrisson
48898993b9 Fix removing of temporary files 2012-11-20 16:51:19 +01:00
Daniel Hokka Zakrisson
0ebf4b2d5a Add destination path to fetch result 2012-11-20 15:39:48 +01:00
Daniel Hokka Zakrisson
bdf05ec9a0 Use runner's basedir as cwd for -c local 2012-11-20 15:36:43 +01:00
Daniel Hokka Zakrisson
f89f07871d Fix typo in first_available_file error path 2012-11-19 23:02:26 +01:00
Daniel Hokka Zakrisson
f95fefd8c5 Use plugin system to find modules 2012-11-18 19:09:21 +01:00
Daniel Hokka Zakrisson
5dd2ec2cae Add a way to add directories to just one type of loader 2012-11-18 19:08:59 +01:00
Daniel Hokka Zakrisson
d2abfb9ff8 Ensure runner adds its basedir, so ansible can benefit from plugins 2012-11-18 18:37:20 +01:00
Daniel Hokka Zakrisson
5183417de8 Reinstate ANSIBLE_KEEP_REMOTE_FILES
Fixes #1395.
2012-11-18 18:32:45 +01:00
Daniel Hokka Zakrisson
11175781b8 Use slurp for fetch is sudo is enabled and needed
Fixes #1020.
2012-11-18 17:54:00 +01:00
Daniel Hokka Zakrisson
11afd84d32 Drop dwim prefix from returned items in fileglob
Fixes #1618.
2012-11-18 00:25:38 +01:00
Michael DeHaan
1b78dabcd4 Merge pull request #1632 from dhozac/use-ssh-conn-section-for-scp
Use the ssh_connection section for scp_if_ssh
2012-11-17 07:41:35 -08:00
Michael DeHaan
3bc0adacbf Merge pull request #1634 from dhozac/ssh-password
Add password support to -c ssh via sshpass
2012-11-17 07:37:51 -08:00
Daniel Hokka Zakrisson
e6fed9f216 Add password support to -c ssh via sshpass 2012-11-16 23:46:49 +01:00
Daniel Hokka Zakrisson
021172f78d Use the configured remote_tmp even for root 2012-11-16 23:46:17 +01:00
Daniel Hokka Zakrisson
c906f44d90 Use the ssh_connection section for scp_if_ssh 2012-11-16 23:45:47 +01:00
Michael DeHaan
ab5c0dfe7e __new__ does not take arguments, remove deprecation warning 2012-11-14 19:58:44 -05:00
Michael DeHaan
096607eea4 Allow fireball to transfer binary files, fixup fireball docs, make fetch work with fireball. 2012-11-14 18:37:17 -05:00
Michael DeHaan
d500398e76 Merge pull request #1616 from dagwieers/skip-register
Do not register variable if host has been skipped
2012-11-14 06:33:30 -08:00
Michael DeHaan
52e2654faf Merge pull request #1621 from dhozac/lookup-with-vars
Lookup plugin arguments need to be templated
2012-11-14 06:32:39 -08:00
Daniel Hokka Zakrisson
17e4ce97a4 Create a set of all the hosts in a group to prevent duplicates
Fixes #1516.
2012-11-14 13:35:21 +01:00
Daniel Hokka Zakrisson
e74ffd6764 Lookup plugin arguments need to be templated 2012-11-14 11:17:30 +01:00
Dag Wieers
302eeae65d Do not register variable if host has been skipped
Executive summary: skipping a host corrupts a variable (when it is registered)

We have a play existing out of multiple tasks that check a condition, if one of these tasks fails we want to skip all next tasks in the playbook. I noticed that if we skip a task because a certain condition is met, and this task has a register-attribute, I loose the value in the variable. Which means we cannot use that variable in subsequent tasks to evaluate because it was skipped:

```
- action: command test -d /some/directory
  register: task

- action: command test -f /some/directory/file
  register: task
  only_if: '${task.rc} == 0'

- action: do something else
  only_if: '${task.rc} == 0'
```

In the above example, if the second task is skipped (because the first failed), the third action will end with a "SyntaxError: invalid syntax" complaining about the unsubstituted ${task.rc} (even though it was set by the first task and used for skipping the second).

The following play demonstrates the problem:

```
- name: Test register on ignored tasks
  hosts: all
  gather_facts: no

  vars:
    skip: true
    task: { 'rc': 666 }

  tasks:
  - action: debug msg='skip = ${skip}, task.rc = ${task.rc}'

  - name: Skip this task, just to test if task has changed
    action: command ls
    register: task
    only_if: '${skip} != True'

  - action: debug msg='skip = ${skip}, task.rc = ${task.rc}'

  - name: Now use task value
    action: command echo 'Works !'
    only_if: '${task.rc} == 0'
```

And the enclosed fix, fixes the above problem.
2012-11-13 16:57:10 +01:00
Michael DeHaan
44af1408ee Merge pull request #1611 from dhozac/no-hostvars-templating
Keep hostvars from being templated
2012-11-13 05:20:48 -08:00
Michael DeHaan
6793bcbe4d Merge pull request #1613 from dhozac/use-all-vars-for-hosts-template
Use all available vars for hosts:, user: and sudo_user:
2012-11-13 04:47:03 -08:00
Michael DeHaan
2303f65a1a Merge pull request #1614 from dagwieers/missing-action-error
Print the task name (if any) when complaining
2012-11-13 04:46:41 -08:00
Dag Wieers
b96877e5aa Print the task name (if any) when complaining
After spending 10 minutes to find which playbook had an action/local_action missing, I changed the error to include the task name (if set). The error eventually was caused because I added a name to a task, but the dash before the existing action was not removed.
2012-11-13 12:53:42 +01:00
Daniel Hokka Zakrisson
0be1f11ed5 Use all available vars for hosts:, user: and sudo_user: 2012-11-13 12:20:07 +01:00
Daniel Hokka Zakrisson
eebbbd3f0e Make parameterized playbook includes work with vars as a list
Fixes #1610.
2012-11-13 12:12:18 +01:00
Daniel Hokka Zakrisson
c200c26ced Keep hostvars from being templated 2012-11-13 11:34:34 +01:00
Michael DeHaan
e3f7f86ac4 Merge pull request #1608 from dhozac/when_set-non-string
Try to ensure the entire value is quoted
2012-11-12 17:45:47 -08:00
Michael DeHaan
d5be13c3f0 Merge pull request #1605 from romeotheriault/add-md5-support-to-fetch-module
add bsd md5 support to fetch module
2012-11-12 17:45:07 -08:00
Daniel Hokka Zakrisson
0ca1775bda Try to ensure the entire value is quoted 2012-11-13 02:40:29 +01:00
Daniel Hokka Zakrisson
25a8787e95 Template all variables before returning them to Jinja2 2012-11-13 02:39:33 +01:00
Daniel Hokka Zakrisson
d2dce1d63f Make lookup plugin replacements part of the main variable logic 2012-11-13 02:18:05 +01:00
Daniel Hokka Zakrisson
a2bb3a09d2 Completely ignore stray $ in input
Previously, "a $ string $var" would not have gotten replaced at all.
2012-11-13 02:13:10 +01:00
Daniel Hokka Zakrisson
24b536d7ed Add some comments to templating system 2012-11-13 02:13:04 +01:00
Romeo Theriault
4cd133ed8f add bsd md5 support to fetch module 2012-11-12 10:37:00 -10:00
Daniel Hokka Zakrisson
233a36b9e8 Template using module_vars early
Since no basedir is available at that time, avoid invoking
lookup plugins since they assume it is present.
2012-11-12 16:53:24 +01:00
Michael DeHaan
c890ae18e7 Merge pull request #1575 from dhozac/parameterized-playbook-include
Add parameterized playbook includes
2012-11-12 05:17:38 -08:00
Michael DeHaan
3e855a5fcd Merge pull request #1593 from dhozac/lookup_generic
Add support for generic $XXX() to call $LOOKUP()
2012-11-12 05:07:52 -08:00
Michael DeHaan
451f05fa3d Merge pull request #1594 from sfromm/issue1342
Add ability to specify syslog facility for modules
2012-11-12 05:06:47 -08:00
Romeo Theriault
54b7f59416 remove verbose option on digest call 2012-11-11 19:43:40 -10:00
Stephen Fromm
06e54c0b97 Add ability to specify syslog facility for modules
Update constants.py so that one can specify environmental variable
ANSIBLE_SYSLOG_FACILITY or syslog_facility in ansible.cfg to define
the syslog facility to use.  Alternatively, you can specify
ansible_syslog_facility in inventory.  Runner now replaces
the syslog facility in the openlog() call with the default or
the injected variables ansible_syslog_facility.

This also updates hacking/test-module to behave similarly.
2012-11-11 00:14:08 -08:00
Daniel Hokka Zakrisson
9924555623 Add support for generic $XXX() to call $LOOKUP() 2012-11-10 23:46:37 +01:00
Michael DeHaan
40e49b6a5a Merge pull request #1592 from jpmens/lookup_dnstxt3
$LOOKUP(dnstxt): handle exceptions
2012-11-10 08:52:30 -08:00
Jan-Piet Mens
bd55899a60 $LOOKUP(dnstxt): handle exceptions
de-spaced
2012-11-10 17:50:21 +01:00
Michael DeHaan
db3e8c0803 Merge pull request #1579 from jpmens/lookup_env
Add environment $LOOKUP plugin
2012-11-10 06:30:37 -08:00
Michael DeHaan
35679e0093 Merge pull request #1578 from jpmens/lookup_redis
Add Redis GET $LOOKUP plugin
2012-11-10 06:30:10 -08:00
Jan-Piet Mens
6efc98e8a3 Add environment $LOOKUP plugin
remove support for multiple vars
2012-11-10 08:26:09 +01:00
Jan-Piet Mens
e3e545418d Add Redis GET $LOOKUP plugin
renamed
2012-11-10 08:21:48 +01:00
Jan-Piet Mens
e32f4a0564 Move get_docstring from module_formatter into ansible/utils 2012-11-09 17:15:41 +01:00
Daniel Hokka Zakrisson
9c095b72b9 Add parameterized playbook includes
Also makes with_* work with them.

Fixes #1162.
2012-11-09 15:43:49 +01:00
Daniel Hokka Zakrisson
383dc30560 Rename varReplaceWithItems to template_ds 2012-11-09 15:43:29 +01:00
Michael DeHaan
325025a5b6 Merge pull request #1574 from dhozac/ssh-moar-data
Make sure we get all data
2012-11-09 05:08:27 -08:00
Michael DeHaan
fa17540a06 Merge pull request #1570 from skvidal/addhost
Addhost module
2012-11-09 04:51:15 -08:00
Daniel Hokka Zakrisson
e97a22603f Make sure we get all data 2012-11-09 11:24:57 +01:00
Jan-Piet Mens
38d9dc8bff Add DNS TXT record LOOKUP plugin 2012-11-09 11:06:49 +01:00
Seth Vidal
70d61fe7e8 need to use the variabled results 2012-11-09 00:16:17 -05:00
Seth Vidal
e147ad4213 add add_host action plugin - add hosts to inventory during a playbook
run - lets act on those hosts in the next play
2012-11-09 00:16:17 -05:00
Michael DeHaan
03591e0fc8 Merge pull request #1551 from dagwieers/local_action-fail
Turn 'fail' and 'debug' modules into action_plugins
2012-11-08 16:47:24 -08:00
Michael DeHaan
a31ca213a5 Merge pull request #1562 from dagwieers/oneline-fix
Make --oneline return one line (except with multiline output)
2012-11-08 16:45:33 -08:00
Michael DeHaan
03f4b0f923 Merge pull request #1560 from dagwieers/module-output-consistency
Make module output more consistent wrt. changed/failed
2012-11-08 16:45:05 -08:00
Michael DeHaan
3dc31a049f Merge pull request #1527 from fdavis/devel
Support scp in an ssh connection
2012-11-08 16:42:37 -08:00
Dag Wieers
d42eb2563b Make --oneline return one line (except with multiline output)
Currently the message prepared for --oneline mode adds a newline to the msg-string, which is then printed (adding another newline). This change removes the added newline so that successes and failures do not differ in output (except if the output is multiline).
2012-11-08 14:49:40 +01:00
Dag Wieers
fe0c70fe9d Make module output more consistent wrt. changed/failed
- Make sure exit_json() always returns a changed= value
- Modify the yum module to not return failed=False
- Modify install() and latest() similar to remove() in yum module
- Changed exit_json(failed=True, **res) into a fail_json(**res)
- Make sure yum rc= value reflects loop (similar to how we fixed remove())
2012-11-08 12:28:18 +01:00
Dag Wieers
dd07011a65 Only print 'Invoked with' if there are arguments to the module
This closes #1519
2012-11-07 23:51:44 +01:00
Dag Wieers
d8459425a0 Turn 'fail' and 'debug' modules into action_plugins
This makes more sense as there is no purpose in running these remotely.
2012-11-07 23:34:53 +01:00
Daniel Hokka Zakrisson
47082a9171 Add $LOOKUP(<lookup plugin>,<data>) as a templating option
Also moves file and pipe to lookup_plugins.
2012-11-07 23:17:29 +01:00
Michael DeHaan
a1f7334634 Merge pull request #1525 from jhoekx/custom-filter-plugins
Support custom jinja2 filters.
2012-11-07 13:55:21 -08:00
Michael DeHaan
c9ae19c44c Merge pull request #1547 from dagwieers/action-boolean
Bail out if an action is not a string
2012-11-07 13:52:07 -08:00
Dag Wieers
c9e62d7061 Fix for an exception when for whatever reason the inventory script fails
This avoids a traceback that gave no clue as to what was happening.

This is in line with the change from #1535
2012-11-07 15:16:00 +01:00
Dag Wieers
dfa1e8b0dc Bail out if an action is not a string
Since YAML allows anything, we should enforce that actions are strings.

This closes #1419.
2012-11-07 15:04:04 +01:00
Michael DeHaan
75d3b77454 Merge pull request #1535 from dagwieers/inventory-exception
Fix for an exception when for whatever reason the inventory script fails
2012-11-07 04:06:33 -08:00
Daniel Hokka Zakrisson
00aa584c57 Don't double dwim first_available_file in template 2012-11-06 20:34:05 +01:00
Dag Wieers
89206a6b68 Fix for an exception when for whatever reason the inventory script fails
This avoids a traceback that gave no clue as to what was happening.
2012-11-06 16:39:10 +01:00
fdavis
b1dbeec66c Allows use of scp instead of sftp in
Added a boolean constant scp_if_ssh to the config
Added scp support for the ssh connection plugin
Refers to #1279
2012-11-05 14:25:40 -08:00
Jeroen Hoekx
8ffed6df75 Support custom jinja2 filters.
This uses the plugin framework to add filter plugins.
The previously hardcoded core filters are defined using the plugin
framework now.
2012-11-05 15:11:34 +01:00
Michael DeHaan
6f938c9f4c Merge branch 'playbook_ssh_ask_pass' of git://github.com/clatour/ansible into devel
Conflicts:
	examples/ansible.cfg

+ doc tweak
2012-11-03 19:23:38 -04:00
Michael DeHaan
908c43ad7f Merge branch 'devel' of git://github.com/skorokithakis/ansible into devel 2012-11-03 19:19:59 -04:00
Michael DeHaan
05de2152a0 Merge branch 'sudo_ask_pass_config' of git://github.com/bcoca/ansible into devel 2012-11-03 19:09:40 -04:00
Michael DeHaan
154a00e612 Merge branch 'plugin-sanity' of git://github.com/dhozac/ansible into try_new_plugins 2012-11-03 19:04:23 -04:00
Michael DeHaan
c96f2c968e Merge branch 'nigelm_freebsd' of git://github.com/nigelm/ansible into merge-service
Make things more reusable, correct some errors along the SSH key path

Conflicts:
	library/user
2012-11-03 18:38:05 -04:00
Seth Vidal
e19c81977d if a module returns failed in the results, don't fail unless failed is not false. 2012-11-02 15:24:17 -04:00
Chandler Latour
f436a8c88b Added config option for default ask for ssh_pass 2012-11-02 10:53:26 -05:00
Daniel Hokka Zakrisson
e05e514861 Create a plugin loader system 2012-11-02 01:24:14 +01:00
Daniel Hokka Zakrisson
000d3832cc Make ansible.utils a package 2012-11-02 00:42:37 +01:00
Stavros Korokithakis
3616dffb68 Detect whether we're running in a virtualenv. 2012-11-02 01:42:04 +02:00
Michael DeHaan
4c156e4df8 Merge pull request #1502 from dhozac/improved-lookup-plugins
Improved lookup plugins
2012-11-01 16:36:03 -07:00
Michael DeHaan
025402c0bf Merge pull request #1507 from lorin/pretty-print-msg
Pretty-print "msg" when task fails
2012-11-01 16:33:41 -07:00
Stavros Korokithakis
d9a377cbb1 Fix installing to virtualenvs. 2012-11-01 20:40:28 +02:00
Daniel Hokka Zakrisson
07ba7e2013 Return original string for non-matched vars 2012-11-01 18:53:23 +01:00
Lorin Hochstein
1c5ac5cac8 Pretty-print "msg" when task fails
Several modules (e.g., pip) return stdout and stderr together in a "msg" variable (and the module development docs seem to suggest that the standard practice is to return status in this variable).

This change ensures that it is printed out with correct formatting (most importantly, with newlines appearing as newlines instead of \n).
2012-11-01 13:23:18 -04:00
Daniel Hokka Zakrisson
fbda2d4628 Use default port if ansible_ssh_port is not set for the delegated node
Also add testcase for it.
2012-11-01 12:00:49 +01:00
Daniel Hokka Zakrisson
c519d5dac0 Add a template lookup plugin
Requires that inject be passed to run
2012-10-31 16:57:10 +01:00
Daniel Hokka Zakrisson
37d9acc097 Make lookup API extensible and allow basedir to be passed
This allows using with_fileglob in play context, e.g.
- include: $item
  with_fileglob: tasks/*.yml
as well as prepares for other data to be passed.
2012-10-31 16:55:38 +01:00
Daniel Hokka Zakrisson
2c77cf1a49 Skip tasks with a with_* that is empty 2012-10-31 16:37:26 +01:00
Brian Coca
604bf9f58a Added config option to control default of asking or not for sudo password
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2012-10-30 23:36:07 -04:00
Michael DeHaan
be300b562a pyflakes fixes (mostly unused imports, unused vars) 2012-10-30 20:47:05 -04:00
Michael DeHaan
c0747b7baa pep8 fixes 2012-10-30 20:42:07 -04:00
Michael DeHaan
0853ece810 Merge pull request #1474 from jhoekx/group-by-plugin-template
Add a group_by action plugin.
2012-10-30 16:54:07 -07:00
Michael DeHaan
f9a6265fb2 Merge branch 'vars_files-list-no-default' of git://github.com/dhozac/ansible into devel 2012-10-30 19:50:31 -04:00
Michael DeHaan
6dceef3a5f Merge branch 'fix-var-in-var' of git://github.com/dhozac/ansible into devel 2012-10-30 19:48:32 -04:00
Daniel Hokka Zakrisson
efe83daf19 Fix ${var.$other_var} and add test cases for it 2012-10-30 13:05:45 +01:00
Michael DeHaan
9a12873166 Merge pull request #1477 from skvidal/devel
add check that vars plugins are not handing back None
2012-10-29 16:02:26 -07:00
Seth Vidal
3fcc591f18 add check that vars plugins are not handing back None 2012-10-29 12:11:57 -04:00
Dag Wieers
3728b2f459 Missing errors-import causes traceback 2012-10-29 15:16:26 +01:00
Jeroen Hoekx
b336d40101 Add a group_by action plugin. 2012-10-29 13:10:23 +01:00
Jeroen Hoekx
f963db6c2a Fix output of pause plugin. 2012-10-29 10:57:13 +01:00
Jeroen Hoekx
77162e95e4 Send a host to runner executor instead of a letter.
Discovered in #1463 .
2012-10-29 09:45:44 +01:00
Daniel Hokka Zakrisson
e72fdccd87 Allow vars_files sequences without a default 2012-10-28 16:35:22 +01:00
Daniel Hokka Zakrisson
55a1473d50 Don't add file module arguments by default
This allows the postgresql_db module to work properly, as it uses
an argument named owner that conflicts with the file module.
2012-10-28 11:14:29 +01:00
Michael DeHaan
21258dcc66 Added 'when' as a shortcut around only_if. 2012-10-27 17:55:35 -04:00
Michael DeHaan
a768e9a9ff Fix for sudo defaults if sudo is passed in via --extra-vars 2012-10-27 16:46:33 -04:00
Michael DeHaan
6ba30170dd Make group_vars and host_vars available to usr/bin/ansible, and make vars_plugins exist 2012-10-26 19:55:59 -04:00
Michael DeHaan
e04dab904a Use previous proven multiprocessing logic as the simplification didn't have the same Ctrl-C handling and may
be subject to race issues, though still don't pass Runner to each.  Still seems performant.
2012-10-26 18:11:38 -04:00
Daniel Hokka Zakrisson
1052dd9c8f Initialize sftp variable to fix error on transferless session 2012-10-26 23:54:21 +02:00
Michael DeHaan
5e2c2564bc Explicitly execute /bin/sh versus $SHELL because some folks have very incompatible/weird shells. We do not
execute modules through the shell, this is only for basic ops, so should be sufficient.
2012-10-25 23:00:07 -04:00
Michael DeHaan
ff787146d1 stray debug 2012-10-25 22:24:15 -04:00
Michael DeHaan
24416b9e49 Remove stray debug message 2012-10-25 22:19:50 -04:00
Michael DeHaan
3257c5b61f Some caching improvements to paramiko which are still not yet fully leveraged
in playbook mode, since the Runner still closes abstract host connections completely
and does not have a LRU.
2012-10-25 22:09:54 -04:00
Michael DeHaan
4c83c274e0 Don't close paramiko SFTP multiple times in the same runner pass. Noticeable performance increase. 2012-10-25 21:49:28 -04:00
Michael DeHaan
8b50ad7e85 Fix for atomic_replace patch if file does not yet exist 2012-10-25 21:40:05 -04:00
Daniel Hokka Zakrisson
7a8009f979 When atomically replacing files, copy attributes 2012-10-25 21:40:05 -04:00
Michael DeHaan
19a5f86c2e Merge pull request #1452 from dhozac/with_items-as-plugin
Make with_items a lookup plugin
2012-10-25 18:24:34 -07:00
Michael DeHaan
9a141160a4 Merge pull request #1449 from dhozac/localhost-interpreters
Use the delegated host's interpreters
2012-10-25 18:19:26 -07:00
Michael DeHaan
347b0260c3 Merge varReplace cleanup and move code into new file 'template.py' so it's easier to keep template
code all together.
2012-10-25 21:18:08 -04:00
Michael DeHaan
f8e946b71d Merge branch 'varfind-cleanups' of git://github.com/dhozac/ansible into devel 2012-10-25 20:14:20 -04:00
Daniel Hokka Zakrisson
2f05e95d8a Use lookup plugins for task include with_* 2012-10-25 15:13:34 +02:00
Daniel Hokka Zakrisson
026e251b94 Make with_items a lookup plugin 2012-10-25 15:10:33 +02:00
Michael DeHaan
ffca0283b0 Closing pool explicitly may cause some exceptions on certain Pythons, disable for now. 2012-10-25 09:07:33 -04:00
Daniel Hokka Zakrisson
13a422261b Use the delegated host's interpreters 2012-10-25 14:10:04 +02:00
Michael DeHaan
bbe66e7610 Merge pull request #1437 from lorin/sudo-nonroot-bugfix
Fix chmod occurring as wrong user when sudo as non-root
2012-10-24 17:01:32 -07:00
Michael DeHaan
9fca4eb241 Merge pull request #1441 from dhozac/better-error-missing-template
Improve the error message for missing files
2012-10-24 16:58:28 -07:00
Daniel Hokka Zakrisson
b1200c16df path_dwim the path given to with_fileglob 2012-10-25 00:52:42 +02:00
Daniel Hokka Zakrisson
e216116807 Improve the error message for missing files 2012-10-25 00:30:05 +02:00
Lorin Hochstein
38fdc24966 Fix chmod occurring as wrong user when sudo as non-root
If you sudo to a non-root user, you get a permission denied error.
Here's an example:

    $ ansible myserver.example.com -m postgresql_db -a "db=mydatabase" -u ubuntu -s -U postgres
    myserver.example.com | FAILED >> {
        "failed": true,
        "msg": "chmod: changing permissions of `/tmp/ansible-
        1351092257.96-157699143369671/postgresql_db': Operation not
        permitted\n/usr/bin/python: can't open file '/tmp/ansible-
        1351092257.96-157699143369671/postgresql_db': [Errno 13]
        Permission denied\n",
        "parsed": false
    }

The problem is that ansible is doing the chmod as the sudo user
when it should be doing it as the remote user.
2012-10-24 11:30:56 -04:00
Michael DeHaan
f1f44843c3 close the pool. 2012-10-24 07:56:23 -04:00
Michael DeHaan
92ce8a0517 Refine new keyboard interrupt handling. Output still a bit gross. 2012-10-24 07:46:24 -04:00
Michael DeHaan
47b1315ac7 Reinstate Ctrl+C handling 2012-10-24 07:40:48 -04:00
Michael DeHaan
a4af4a7049 Since we are not needing to pass runner through the multiprocessing queue, just use
multiprocessing.pool.  Pushing so it can get wider testing.
2012-10-23 08:19:15 -04:00
Michael DeHaan
856dd5a9aa Don't pass runner instance through the mulitprocessing queue, fix temp dir removal 2012-10-23 08:04:32 -04:00
Seth Vidal
d63fa6f026 make --limit take a , as a separator as well as ; or : 2012-10-22 21:24:25 -04:00
Michael DeHaan
109632e3bc Revert "Vars specified via CLI have the highest priority."
Reverting as this as reported allows some variables to clobber each other.
We'll work on a different fix.

This reverts commit c5469f6367.
2012-10-21 16:42:15 -04:00
Daniel Hokka Zakrisson
1449c8ac67 Fix ansible_ssh_host again
This time with unit tests to ensure it keeps working.
2012-10-21 21:22:56 +02:00
Daniel Hokka Zakrisson
c9c5fc1456 Merge varFind and varLookup 2012-10-21 20:32:02 +02:00
Michael DeHaan
3c6d9972fe clarify message about name of configuration parameter 2012-10-21 07:12:06 -04:00
Michael DeHaan
cbc12f0dba Various performance streamlining and making the file features usable in all modules without daisy chaining. 2012-10-20 22:55:09 -04:00
Michael DeHaan
4104478abd Added 'script', a module that can push and insantly run a remote script. Replaces the need to copy+command.
This is a bit of a rough draft, some error handling still needs to be added.
2012-10-20 12:12:07 -04:00
Michael DeHaan
019f775a93 DWIM the paths for first_available_file 2012-10-20 11:11:31 -04:00
Michael DeHaan
6fa1a49037 Fix the basic templating system such that when the template ends in '$', life continues as normal. 2012-10-20 10:57:52 -04:00
Michael DeHaan
ed9f5eed09 Merge pull request #1338 from alopropoz/extra_vars_override
Vars specified via CLI have the highest priority.
2012-10-20 07:29:12 -07:00
Michael DeHaan
5bdc16338e Release version bump for 0.9 (development branch) 2012-10-19 21:01:57 -04:00
Michael DeHaan
cde377bddb Merge pull request #1385 from dhozac/raise-error-for-scripts-too
Raise error for missing hosts in inventory scripts as well
2012-10-19 07:30:01 -07:00
Daniel Hokka Zakrisson
b8021f12e0 Raise error for missing hosts in inventory scripts as well 2012-10-19 16:26:12 +02:00
Daniel Hokka Zakrisson
e3d18048d4 None is unfortunately not an integer 2012-10-19 16:18:38 +02:00
Michael DeHaan
d509dfc969 delete extra else clause 2012-10-18 20:27:39 -04:00
Michael DeHaan
452668ce83 Merge branch 'devel' of git://github.com/willthames/ansible into devel 2012-10-18 20:23:10 -04:00
Michael DeHaan
31b45479e8 When using delegation, local_action should always use the local connection type. 2012-10-18 20:18:33 -04:00
Daniel Hokka Zakrisson
979999b886 Port should be an integer 2012-10-18 21:48:57 +02:00
Daniel Hokka Zakrisson
19797e1a29 Accessing a node that doesn't exist throws an exception 2012-10-18 21:48:10 +02:00
willthames
5a769a5a4d Fixed tests to reflect desired configuration behaviour
Test for when environment variable and configuration file
variable both set now tests that the environment variable takes
precedence

Removed logic that would never be triggered from
lib/ansible/constants.py
2012-10-18 12:53:30 +10:00
Michael DeHaan
556799a7c4 add error message if keyczar is not installed and the user tries to use fireball mode 2012-10-17 22:53:22 -04:00
Michael DeHaan
d5db8e937e Fix port overrides such that with fireball mode you don't have to specify an explicit port. 2012-10-17 22:50:17 -04:00
Michael DeHaan
fd6a26239c Env var vs config priority fixing 2012-10-17 22:34:59 -04:00
Michael DeHaan
0837a29e51 Only expand lists in templating inside of module action lines, to avoid breaking usage with with_items and "in" statements, etc 2012-10-17 19:35:12 -04:00
Michael DeHaan
acf2c23808 Various tweaking of the delegate_to loop code. 2012-10-17 19:17:41 -04:00
Daniel Hokka Zakrisson
37b91c7b81 Fix ansible_ssh_host after 339c05bb 2012-10-17 19:17:41 -04:00
Daniel Hokka Zakrisson
519a1f3f23 Remove debug print statements 2012-10-17 22:45:17 +02:00
Michael DeHaan
22e3e7f323 Allow use of variables in delegate_to 2012-10-16 21:05:09 -04:00
Michael DeHaan
a69e59ab2b Allows delegate_to to use inventory host/port info. 2012-10-16 20:57:37 -04:00
Michael DeHaan
8c3abe7e52 Fix cowsay! Moo. 2012-10-16 20:01:12 -04:00
Michael DeHaan
63100c9bc0 Docs + fix variable precedence of environment variables (ok, ok, I give in!) 2012-10-16 18:40:01 -04:00
Michael DeHaan
f3407dec0e Merge branch 'basedir-plugins' of git://github.com/dhozac/ansible into devel 2012-10-16 18:00:55 -04:00
Aleksej Romanov
c5469f6367 Vars specified via CLI have the highest priority. 2012-10-16 04:34:54 +07:00
Brian Coca
e98153d26d cowsay for BSD!
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
2012-10-15 10:17:21 -04:00
Daniel Hokka Zakrisson
ab44a4abba Load additional plugins from path specified in configuration 2012-10-14 21:09:24 +02:00
Daniel Hokka Zakrisson
1aaf86069a Look for plugins in the playbook's basedir 2012-10-14 21:09:23 +02:00
Michael DeHaan
c5d2f6b0d3 implement lookup plugins for arbitrary enumeration over arbitrary things. See the mailing list for some cool examples. 2012-10-12 20:07:05 -04:00
Michael DeHaan
271db7bddb Merge pull request #1308 from abondis/named_action
named actions + modules list in utils.py
2012-10-12 14:33:43 -07:00
Aurélien Bondis
6d183959ba #1303: add sudo option to tasks 2012-10-12 12:39:45 -04:00
Aurélien Bondis
2063e10c00 named actions + modules list in utils.py 2012-10-12 11:28:10 -04:00
Michael DeHaan
5849ab3162 Merge pull request #1300 from tbielawa/fix_module_path
Add DIST_MODULE_PATH so setup.py and ansible.spec can live in harmony
2012-10-11 17:30:23 -07:00
Daniel Hokka Zakrisson
b8b34b5110 Keep processing the rest of the vars_files even if one has vars 2012-10-11 23:52:01 +02:00
Tim Bielawa
baa91ebc95 Add DIST_MODULE_PATH so setup.py and ansible.spec can live in harmony. Closes #1277 2012-10-11 13:22:30 -04:00
Michael DeHaan
f3d7294690 Test for directory existance, fix exception catching granularity 2012-10-11 07:56:01 -04:00
Michael DeHaan
448c89a06d It has been reported that occasionally the md5sum command on certain platforms (?) can fail, where I suspect there is noise in the output stream.
In those events, capture the output so we can report the error more properly.
2012-10-11 07:44:41 -04:00
Michael DeHaan
7e542d78a7 Merge remote branch 'stijnopheide/jinja-relative' into devel
Conflicts:
	.gitignore
2012-10-10 20:24:12 -04:00
Michael DeHaan
e2497f0cff Merge remote branch 'abondis/named_actions_2' into devel 2012-10-10 19:53:19 -04:00
Jeroen Hoekx
23a62f5a78 Return multiple groups from inventory API. 2012-10-10 18:35:45 +02:00
Aurélien Bondis
e07bfd9ef8 playbook/tasks: allow to use a module's name instead of action: 2012-10-09 00:21:13 -04:00
Michael DeHaan
04954dbc1e Makes ports configurable for fireball. Note port defaults really belong in the connection plugins, not runner, which can be refactored later. 2012-10-08 19:03:37 -04:00
Jeroen Hoekx
46a4ae74a7 Add inventory variables to hostvars.
Look up only when requested and cache the result.
2012-10-08 20:26:58 +02:00
Stijn Opheide
4a6b5c5de2 relative paths for (include/extends) in jinja2 templates 2012-10-08 08:56:57 +02:00
Michael DeHaan
26bbac3062 Merge pull request #1246 from jpmens/nocows
Not for cow lovers: optionally disable cowsay
2012-10-07 06:11:29 -07:00
Jan-Piet Mens
051f66cf16 Not for cow lovers: optionally disable cowsay
spaces now cow-compatible
2012-10-07 11:23:42 +02:00
Marko Mikulicic
cc82e7dd06 Added a ANSIBLE_FORCE_COLOR env var, which forces the color output no matter what ncurses says. 2012-10-06 20:36:07 +02:00
Michael DeHaan
ebc2fe08c3 Merge pull request #1218 from jpmens/jtempl3
Allow user-specified $ansible_managed string
2012-10-04 16:18:57 -07:00
Jan-Piet Mens
9ed59da294 Allow user-specified $ansible_managed string with named parameters 2012-10-04 08:50:51 +02:00
Tim Bielawa
9f6da7b885 Fix variable injection in pause module args. Closes #1209 2012-10-03 23:52:26 -04:00
Michael DeHaan
d14741799a Merge pull request #1204 from dagwieers/fatal-red
Make fatal errors red
2012-10-02 19:06:36 -07:00
Michael DeHaan
459d9ea30d Merge pull request #1205 from dagwieers/ignore-cyan
Make ignored/skipped different from changed
2012-10-02 19:06:14 -07:00
Michael DeHaan
212296e59c Merge pull request #1207 from dagwieers/gather_facts-fix
Fix gather_facts assumption that SETUP_CACHE for a host is empty
2012-10-02 19:05:54 -07:00
Michael DeHaan
cef73d1545 Merge pull request #1202 from dagwieers/abort-play-abort-playbook
Abort a play at the start when no hosts matches, or no hosts are remaining
2012-10-02 19:02:27 -07:00
Dag Wieers
fedfd18774 Fix gather_facts assumption that SETUP_CACHE for a host is empty
We now check explicitely for 'module_setup' in the SETUP_CACHE in order to avoid skipping setup because SETUP_CACHE was populated some other way. Other modules can implement the same mechanism to test if they've already run.

This closes #1206.
2012-10-02 23:17:45 +02:00
Dag Wieers
f11ab4383a Make ignored/skipped different from changed
Since a skipped/ignored action is _very_ different from actual changes to a system, it always bothered me that  it was not easily distinguishable when skimming the output. This change makes ignore/skip a different color, and I chose cyan. Contemplated using dark-gray/blue, but prefered something that is readable with most terminal colors.
2012-10-02 21:49:04 +02:00
Dag Wieers
7acc0a632b Make fatal errors red 2012-10-02 21:45:42 +02:00
Dag Wieers
20c1a67711 Abort a play at the start when no hosts matches, or no hosts are remaining
This change makes a distinction between no_hosts_matched and no_hosts_remaining.

In both cases we do not start facts-gathering, or run any tasks.

In the case that there are no more hosts remaining, we abort running tasks and abort the playbook.

I also cleaned up the leftovers from the previous patchsets, as these are no longer required.

This closes #1187.

Example playbook:

```yaml
---
- hosts: emptygroup
  tasks:
  - action: command date
  - action: command false

- hosts: all
  gather_facts: False
  tasks:
  - action: command ls
  - action: command false
  - action: command true

- hosts: all
  tasks:
  - action: command true
  - action: command false

- hosts: all
  tasks:
  - action: command pwd
```
2012-10-02 15:54:24 +02:00
Daniel Hokka Zakrisson
564a212b3c Only gather facts once per node per playbook run
Unless gather_facts: True is on the play
2012-10-02 15:30:19 +02:00
Jan-Piet Mens
5f04ef8b4c Feature: file info on templates accessible to Jinja2 templates
add ansible_managed
2012-10-02 14:15:27 +02:00
Michael DeHaan
14f7c85ce7 Include a space and a colon after prompts, so you don't have to put them in yourself. Consistent with documented behavior in examples/playbooks/prompts.yml 2012-10-01 22:15:34 -04:00
Michael DeHaan
b90eccc4f8 Merge pull request #1186 from dhozac/varreplacewi-nonstr
Allow non-string types in with_items variables
2012-10-01 19:10:05 -07:00
Michael DeHaan
5683277e4a Be smarter about when to abort a playbook -- if it's early, we just didn't match any hosts, so keep on, hosts might be dynamic. 2012-10-01 22:07:08 -04:00
Daniel Hokka Zakrisson
48c5d696d2 Remove debug print statement 2012-10-01 17:23:21 +02:00
Daniel Hokka Zakrisson
a83aa1071b Give each task its own module_vars
Otherwise each task will overwrite the previous' items, among
other things.
2012-10-01 17:17:39 +02:00
Daniel Hokka Zakrisson
695b4bcb46 Allow non-string types in with_items variables 2012-10-01 17:07:51 +02:00
Michael DeHaan
a2f76c1c69 If all hosts in a play fail, fail the whole playbook and don't bother printing out every remaining task. 2012-09-30 21:06:00 -04:00
Michael DeHaan
19b78cedc8 Abort a play when there are no more hosts in it. 2012-09-30 20:48:35 -04:00
Michael DeHaan
5846c1b8c4 Merge pull request #1125 from dagwieers/setup-retain
Make sure we retain facts between playbooks
2012-09-30 17:18:40 -07:00
Michael DeHaan
d0eba79760 Template out sudo_user so you can pass in variables using --extra-vars 2012-09-30 20:11:51 -04:00
Michael DeHaan
8e9344eef7 add an error when user tries to async something that can't be asynced 2012-09-30 20:06:55 -04:00
Stephen Fromm
cf3e368d15 Add message reporting skipped action in cli callback 2012-09-30 08:54:20 -07:00
Michael DeHaan
e756ee3741 Merge pull request #1159 from dhozac/include-with_items
Allow task includes to work with with_items
2012-09-30 05:13:32 -07:00
Daniel Hokka Zakrisson
8a8ffa2342 Allow task includes to work with with_items 2012-09-30 13:40:52 +02:00
Daniel Hokka Zakrisson
dfee6e19ca Replace lists with a comma-separated join 2012-09-30 11:41:44 +02:00
Daniel Hokka Zakrisson
62db667760 Fix typo in $FILE() 2012-09-30 01:19:22 +02:00
Michael DeHaan
2d7691500e Merge pull request #1139 from lorin/config-precedence
ANSIBLE_CONFIG take precedence over ./ansible.cfg
2012-09-29 13:27:07 -07:00
Michael DeHaan
1fd5de21d2 Merge pull request #1149 from dhozac/non-greedy-filepipe
Complete the change from $FILE{} to $FILE()
2012-09-29 13:25:32 -07:00
Michael DeHaan
8b55217df0 Merge pull request #1148 from dhozac/multiline-only_if
Allow multiline strings to work okay in only_if
2012-09-29 13:25:07 -07:00
Daniel Hokka Zakrisson
2d81a1fa77 Complete the change from $FILE{} to $FILE()
Otherwise, parsing e.g. '$FILE(myfile)'.find("stuff") will include
everything up to the last ) as the filename.
2012-09-29 21:16:13 +02:00
Daniel Hokka Zakrisson
be9d7df6c4 Allow multiline strings to work okay in only_if
Fixes issue #1137
2012-09-29 21:13:19 +02:00
Daniel Hokka Zakrisson
e655e2f051 Raise AnsibleError if $FILE() or $PIPE() fail 2012-09-29 21:09:57 +02:00
Lorin Hochstein
aa5ef9561d ANSIBLE_CONFIG take precedence over ./ansible.cfg 2012-09-29 10:44:14 -04:00
Michael DeHaan
9377c3f525 Merge pull request #1130 from commandtab/templates-trim-blocks
Setting trim_blocks to True
2012-09-29 05:25:56 -07:00
Michael DeHaan
08a77135f3 Merge pull request #1126 from dagwieers/choices-fix
Fix to make sure only strings are being joined
2012-09-28 16:12:17 -07:00
Collin Allen
7c600ae0d3 Setting trim_blocks to True 2012-09-28 14:58:05 -07:00
Dag Wieers
27b2ae8ddc Fix to make sure only strings are being joined
Since BOOLEANS also contains integers, joining the list returns an error. Easy to test by giving a wrong value to a boolean argument:

    service name=httpd enabled=True

Since True is not in the allowed BOOLEANS, it will cause the error, which in its turn bails out because it joins strings and integers.
We may want to remove the integers from the choices since '0' and '1' are already in the list as strings. Personally I would expect only strings as arguments, not sure where these could be integers ??
2012-09-28 17:51:59 +02:00
Dag Wieers
c84e76e31d Make sure we retain facts between playbooks
This is mandatory if we want to make facts-modules (like network_facts, ilo_facts and esx_facts) work.
2012-09-28 17:44:51 +02:00
Ralph Bean
d25ee940c4 Close zeromq context and socket. 2012-09-28 08:22:53 -04:00
Daniel Hokka Zakrisson
4b29c2cf74 Revert pull request #1091
Automatic quoting of variables in only_if breaks existing playbooks
where entire statements are put in a variable, and other cases. See
issue #1120 for details.
2012-09-28 13:58:23 +02:00
Michael DeHaan
618a519ee3 Merge branch 'varreplace-lessre' of git://github.com/dhozac/ansible into devel 2012-09-27 22:08:38 -04:00
Dag Wieers
e7af005408 Revert only_if for variables and templating prompt
Since the condition was not templated, it wasn't working.
Only variables in local scope were used, which made this not very practical
2012-09-28 01:32:09 +02:00
Daniel Hokka Zakrisson
9e4fac5ebd Create a string parser for varReplace instead of using re
This fixes a few issues,
- ${foo}${bar} would be parsed as a variable named foo}${bar,
  which wouldn't be easily fixed without breaking ${foo.${bar}}
- allows escaping . in variable parts so e.g.
  ${hostvars.{test.example.com}.foo} works

This is slower than using re. 3 million templating calls take about
about twice as long to complete with this compared to the regexp,
from ~65 seconds to ~115 seconds on my laptop.
2012-09-28 01:03:34 +02:00
Michael DeHaan
6506e17eff Merge pull request #1109 from dhozac/fix-varReplace-repr
Fix only_if statements referencing non-string types
2012-09-27 15:57:50 -07:00
Michael DeHaan
6c6f2b46b4 Merge pull request #1110 from dhozac/rm-assemble-ap
Remove assemble action plugin, fix daisychaining
2012-09-27 15:54:27 -07:00
Michael DeHaan
ee5246fc36 Merge pull request #1113 from jpmens/file_pipe
Strip trailing white space from $FILE()/$PIPE()
2012-09-27 15:54:09 -07:00
Jan-Piet Mens
42620d2f19 Strip trailing white space from $FILE()/$PIPE() 2012-09-27 23:47:34 +02:00
Daniel Hokka Zakrisson
b55ef665ba Fix only_if statements referencing non-string types
This fixes e.g. only_if: ${task.changed} which would always
evaluate to true due to it having been replaced by a string for its
boolean value. Also adds a test case to ensure it doesn't get
missed again.
2012-09-27 18:36:52 +02:00
Daniel Hokka Zakrisson
66d0acfde3 Remove assemble action plugin, fix daisychaining 2012-09-27 18:30:08 +02:00
Aleksej Romanov
0db5ccfecb Don't use ssh-agent if password is specified. 2012-09-27 14:57:06 +07:00
Michael DeHaan
69612ba16d The very first start of 'fireball mode', which uses ansible in SSH mode to deploy a ephemeral zeromq daemon (entirely optional) that is will die after
it is no longer used.  No key signing will be required.  At this point, development use only -- NOT complete.
2012-09-26 23:51:59 -04:00
Michael DeHaan
c63189f650 Make output be cleaner on multi-line failed commands and parse errors. 2012-09-25 20:38:12 -04:00
Michael DeHaan
07101085ca Merge pull request #1093 from brainpage/make_local_action_consistant
2 improvements to delegate_to
2012-09-25 17:17:33 -07:00
Daniel Hokka Zakrisson
84f98534ae Make varReplace recursive instead of iterative 2012-09-25 20:14:58 -04:00
Daniel Hokka Zakrisson
d181a64315 Use repr on replacements for only_if 2012-09-25 20:14:58 -04:00
Michael DeHaan
489844f960 Merge pull request #1095 from pas256/devel
Getting negative host pattern matching to work with external inventory
2012-09-25 17:13:32 -07:00
Michael DeHaan
df147ab921 Merge pull request #1089 from tbielawa/runner_pause
Add 'pause' action plugin and support plugins skipping the host loop.
2012-09-25 17:11:54 -07:00
Peter Sankauskas
8a4e969b93 Getting negative host pattern matching to work with external inventory
(same as commit 4caf85e37b, but for
excluded hosts as well as subsets)
2012-09-25 16:16:25 -07:00
Jonathan Palley
faed650bb1 allow vars in delegate_to 2012-09-26 03:47:17 +08:00
Jonathan Palley
620accf117 make delegate_to localhost act like local_action 2012-09-26 02:57:00 +08:00
Michael DeHaan
f8a9541405 add __init__ to action plugins 2012-09-25 08:24:35 -04:00
Michael DeHaan
730b617186 Add init, though it's not really used. 2012-09-25 08:21:59 -04:00
Michael DeHaan
8e71b26264 Fix up 'changed' playbook output patch 2012-09-25 08:07:11 -04:00
Dag Wieers
6b6e3c64c8 Fix a typo in the prompt code
This is unfortunately related to not being able to reuse the same code that was tested.
2012-09-25 11:51:33 +02:00
Tim Bielawa
58a4d2f7b4 Add 'pause' action plugin and support plugins skipping the host loop. 2012-09-25 01:13:35 -04:00
Michael Lambert
5dab2efcdf Fixed obvious bug with missing self parameter to is_executable method 2012-09-24 21:03:45 -04:00
Michael Lambert
29ac1a8efc Replace os.access with stat calls for determining the executability of a given path. 2012-09-24 21:03:45 -04:00
Michael DeHaan
734db4ffe9 Merge pull request #1080 from dagwieers/prompt-only_if
Add an only_if option to vars_prompt to make prompts conditional
2012-09-24 17:42:17 -07:00
Michael DeHaan
9778eaf4f9 Merge branch 'module_args-argument' of git://github.com/dhozac/ansible into devel 2012-09-24 20:39:48 -04:00
Dag Wieers
4e9a970616 Add an only_if option to vars_prompt to make prompts conditional
Sometimes you may want to allow variables through host_vars or inventory, but prompt for a value if it is not set or if the value does not conform to something specific. This option allows you to specify when you want to offer a prompt.

This patch also moves check_conditional to utils, and adds an is_unset() function which is nicer to read:

    only_if: "not is_set('${var}')"

vs

    only_if: "is_unset('${var}')"
2012-09-24 23:55:54 +02:00
Michael DeHaan
b355dca7dd Merge pull request #1081 from dsummersl/changelabel
Modified 'ok' to 'changed' when a change has occured
2012-09-24 13:46:06 -07:00
Dag Wieers
069feb5d9c Template the variable prompt to customize the message
We have a password-prompt for a configurable login name. Since we require to ask the password for this specific login, it is important to indicate what password needs to be prov ided on the prompt. So the prompt needs to be templated. That's what this patch does.
2012-09-24 22:37:51 +02:00
Dane Summers
04c535b1e9 Modified 'ok' to 'changed' when a change has occured 2012-09-24 16:07:56 -04:00
Daniel Hokka Zakrisson
34f7e6ffa0 Pass module arguments as argument instead of keeping it in runner 2012-09-23 23:38:26 +02:00
Michael DeHaan
3939f7a812 Merge pull request #1076 from SleeplessAnnoyedNerd/Issue-1075
[Issue #1075] Fixing setup module fails if PATH is not set on target hos...
2012-09-23 10:23:18 -07:00
Michael DeHaan
f5f17e98ff Merge pull request #1065 from dhozac/varreplace-include
Allow including files through variables
2012-09-23 10:20:26 -07:00
Dietmar Schinnerl
78b7a3a115 [Issue #1075] Fixing setup module fails if PATH is not set on target host 2012-09-22 17:01:37 +02:00
Daniel Hokka Zakrisson
8d97bb4f8e Add an ansible_ssh_host inventory variable 2012-09-22 00:57:55 +02:00
Michael DeHaan
4ded8cb3b3 Change $FILE{} and $PIPE{} to $FILE() and $PIPE() 2012-09-19 17:58:16 +02:00
Daniel Hokka Zakrisson
cc948f339c Allow including files through variables
$FILE{file} will be replaced with the contents of "file"
$PIPE{cat file} will be replaced with the output of "cat file"
2012-09-19 17:57:17 +02:00
Michael DeHaan
b8c4bb9e6e Revert "Allow including files through variables"
This reverts commit bf47bb4753.

Conflicts:

	lib/ansible/utils.py
	test/TestUtils.py
2012-09-19 10:31:23 -04:00
Michael DeHaan
b2af95e4a6 Change $FILE{} and $PIPE{} to $FILE() and $PIPE() 2012-09-18 21:34:55 -04:00
Michael DeHaan
b25b9fd840 Merge pull request #1058 from jkleint/devel
Support iteration over command output in with_items.
2012-09-18 17:55:40 -07:00
Michael DeHaan
544a8e44d7 Merge pull request #1053 from dhozac/varreplace-include
Allow including files through variables
2012-09-18 17:53:02 -07:00
John Kleint
2a002f5c0b Support iteration over command output in with_items.
When the output of a command is stored in a register, this will create a
stdout_lines field in the result object that contains stdout split into a list
of lines.  This list can then be iterated over using with_items.
2012-09-17 16:57:33 -04:00
Daniel Hokka Zakrisson
dd11b01350 Keep delegate_to so all auxiliary logic based on that works 2012-09-17 20:28:14 +02:00
Daniel Hokka Zakrisson
5bb0f6908b Allow transport on tasks, and use it for local_action 2012-09-17 18:28:37 +02:00
Daniel Hokka Zakrisson
bf47bb4753 Allow including files through variables
$FILE{file} will be replaced with the contents of "file"
$PIPE{cat file} will be replaced with the output of "cat file"
2012-09-17 16:03:59 +02:00
Michael DeHaan
58ad934283 Merge pull request #1024 from tima/groups-pb
Made $groups and $group_names variables accessible in with_items
2012-09-11 14:59:05 -07:00
Michael DeHaan
1829d519b5 Merge pull request #1030 from lorin/import-playbook-pathfix
Support import of playbooks in other directories
2012-09-11 14:58:27 -07:00
Michael DeHaan
d7f83471ae Merge pull request #1032 from mavimo/patch-2
Add support for ./ansible.cfg file
2012-09-11 14:56:22 -07:00
John Kleint
1f8696f5c1 Fix inventory.get_hosts when hosts is a list. 2012-09-11 13:00:40 -04:00
Marco Vito Moscaritolo
0cdd081b53 Add support for ./ansible.cfg file
Ansible support configuration in:
```
~/.ansible.cfg
/etc/ansible/ansible.cfg
```

this patch add current user (usefull where user have some different projects) with the oreder:
```
./ansible.cfg
~/.ansible.cfg
/etc/ansible/ansible.cfg
```
2012-09-10 17:57:32 +03:00
Timothy Appnel
9d5a79f586 Made groups.groupname and group_names variables accessible in playbooks.
Also modified code that feeds the groups data structure to templates so
that it resolves groups inside of groups to hostnames.
2012-09-10 10:42:26 -04:00
Lorin Hochstein
b9e100a506 Support import of playbooks in other directories
Previously, importing a playbook in a different directory didn't
work because all of the relative paths were resolved relative to
the top-level playbook.

This patch resolves relative paths on a per-play level instead of
relative to the directory of the top-level playbook.

Also removes the dirname argument from the Play._get_vars method
since this argument wasn't used in the metho dbody.
2012-09-09 22:59:56 -04:00
Michael DeHaan
e795fa1ec2 Merge pull request #1014 from marktheunissen/journald
Fix regex that allows passwords to get into syslog, use journal if available.
2012-09-08 05:22:27 -07:00
Timothy Appnel
20fc6a29d3 Made groups.groupname and group_names variables accessible in playbooks. 2012-09-07 18:07:52 -04:00
Lorin Hochstein
eabbaaec46 Have ansible respect private_key_file option
The ansible command-line tool was ignoring the private_key_file option.
2012-09-07 14:37:32 -04:00
willthames
f456d999a9 Fix templates for non root sudo_user
When using template module, if a restrictive umask is set, the
sudo_user won't be able to read the /tmp/ansible-dir/source file
after it is copied across following _transfer_str

I wonder if this behaviour shouldn't be abstracted somehow (as
this correction also happens after put_file in the copy module too)
2012-09-07 16:35:53 +10:00
Mark Theunissen
c25ead382c Adapt module common code to use the systemd journal if it's available 2012-09-06 17:59:38 -07:00
Michael DeHaan
dc14681530 rename isset to is_set 2012-09-06 20:55:27 -04:00
Michael DeHaan
8621539341 Merge branch 'only_if-isset' of https://github.com/dhozac/ansible into devel 2012-09-06 20:55:11 -04:00
Michael DeHaan
ba97ad13e3 Merge pull request #1010 from tima/yaml-jinja
Added to_yaml and from_yaml filters to Jinja environment.
2012-09-06 17:50:01 -07:00
Michael DeHaan
8a09e1281b Fixup modularized template module 2012-09-06 19:04:27 -04:00
Michael DeHaan
633e513a65 Modular server-side actions (squash merge) 2012-09-06 18:57:04 -04:00
Michael DeHaan
975c323e39 Release version bump 2012-09-06 18:56:38 -04:00
Michael DeHaan
2bf9a92bb6 Don't load plugins starting with "_". 2012-09-06 18:46:15 -04:00
Michael DeHaan
6fb1884a03 Add __init__'s to git 2012-09-06 18:43:28 -04:00
Timothy Appnel
23cd7ad08a Added to_yaml and from_yaml filters to Jinja environment. 2012-09-06 10:19:56 -04:00
Anastasis Andronidis
02510ec2ff --version is now taking the correct head 2012-09-06 15:18:29 +03:00
Daniel Hokka Zakrisson
14db2fa376 Add an isset("$var") function to only_if 2012-09-05 23:18:47 +02:00
Michael DeHaan
f41d3b9bd2 Fix skipped callback 2012-09-04 21:56:32 -04:00
Michael DeHaan
96f257cea1 Fix invocation-output-supression code to still provide invocation data to the callbacks. 2012-09-04 21:16:12 -04:00
Michael DeHaan
2843e31e09 Don't add 'n/a' because if running from source there will be no git 2012-09-04 21:07:29 -04:00
Michael DeHaan
0c386b0514 Merge pull request #993 from andronat/repo-as-submodule
Fixed a parsing HEAD problem, when ansible is checked out as a submodule
2012-09-05 17:04:09 -07:00
Anastasis Andronidis
ba707f56c1 except now returns a 'n/a' version. Some changes in comments 2012-09-05 12:40:14 +03:00
Michael DeHaan
aa704a6111 backuplocal => backup_local for API standardization reasons 2012-09-04 19:49:49 -04:00
Michael DeHaan
b97e2a6f5a Merge branch 'backup-common' of https://github.com/dhozac/ansible into devel 2012-09-04 19:45:39 -04:00
Daniel Hokka Zakrisson
7a201dbb2e Keep result pristine for ignore_errors 2012-09-04 22:40:07 +02:00
Anastasis Andronidis
63b4f8dd80 small typo 2012-09-04 17:12:16 +03:00
Anastasis Andronidis
44a28838db Fault handling for YAML file and gitdir value. 2012-09-04 17:05:00 +03:00
Daniel Hokka Zakrisson
dfcb9d3c2d Move backup to module_common 2012-09-04 16:04:53 +02:00
Anastasis Andronidis
6c8171f6f9 Appended repo_path 2012-09-04 16:28:57 +03:00
Anastasis Andronidis
4e94db3d78 Fixed a parsing HEAD problem, when ansible is checked out as a submodule
Fixed a parsing HEAD problem, when ansible is checked out as a
submodule in git
2012-09-04 16:12:39 +03:00
Michael DeHaan
c04f00e3a6 Fix async callback 2012-09-02 11:20:56 -04:00
Jan-Piet Mens
a37c6ea936 Jinja2 filter from_json added, to_json renamed 2012-08-31 07:30:18 +02:00
Michael DeHaan
f140332ff6 Make it possible in the inventory file to have spaces in host variables 2012-08-30 19:51:46 -04:00
Stephen Fromm
6742e9c3f4 Add option required=(True|False) to get_bin_path and update modules
Added required as optional argument to get_bin_path(). It defaults to
false.  Updated following modules to use required=True when calling
get_bin_path():  apt_repository, easy_install, group, pip,
supervisorctl, and user.
Also removed _find_supervisorctl() from supervisorctl module and updated
_is_running() to not need it.
2012-08-30 11:01:37 -07:00
Stephen Fromm
4e7b67a45a Add option to pass list of dirs to get_bin_path in module_common.py
The optional list is prepended to PATH.
Fix get_bin_path() to use os.path.join().
2012-08-29 17:08:45 -07:00
Stephen Fromm
4c62e495eb Add method get_bin_path to module_common.py
This is meant to assist all the modules that look for the full path of
an executable.  If it is found and is X_OK, returns the full path.
Otherwise, it returns None.
2012-08-29 16:24:49 -07:00
Daniel Hokka Zakrisson
2d448f2a34 Invoke cowsay without going through the shell 2012-08-30 00:11:40 +02:00
Michael DeHaan
00c4c5c4a1 If tags "all" is used, don't choke. 2012-08-28 20:33:36 -04:00
Michael DeHaan
7ec0afbebc Merge pull request #956 from tima/jinja-json-filter
Add tojson filter to jinja environment used by the template module.
2012-08-28 17:24:08 -07:00
Timothy Appnel
d306c8debc Add tojson filter to jinja environment used by the template module. 2012-08-28 18:10:19 -04:00
Michael DeHaan
4caf85e37b Fix --limit for external inventory scripts, slight variant on fix from pull #949 2012-08-27 21:49:12 -04:00
Michael DeHaan
4002cfbdcd Minor string tweak. 2012-08-27 21:31:20 -04:00
Mark Theunissen
2755602dcb Check to make sure that tags passed as parameters actually exist 2012-08-27 21:27:07 -04:00
Daniel Hokka Zakrisson
89a31b0a2a Allow variable expansion for vars that evaluate to false 2012-08-27 15:42:41 +02:00
Michael DeHaan
98483f5252 Merge pull request #942 from dagwieers/color-capability
Check for terminal capabilities if curses is available
2012-08-24 16:44:29 -07:00
Michael DeHaan
cb18b3eb26 Merge branch 'devel' of github.com:ansible/ansible into devel 2012-08-24 19:30:54 -04:00
Dag Wieërs
47f3be3de0 Check for terminal capabilities if curses is available
Normally curses is part of the standard library, but this was not
always the case in the past.

The ANSIBLE_COLOR environment variable and the tty-check have
priority over the curses method (as they are both faster than
the curses test).
2012-08-25 00:45:14 +02:00
Ludovic Claude
b0a4a9e188 Issue #935: filter out __init__ module from the list of callbacks 2012-08-23 20:26:27 +02:00
Derek Carter
de306922b1 scope error with utils.py branch_path 2012-08-23 12:30:34 -04:00
Michael DeHaan
91a9d0d499 Merge pull request #930 from elventear/version_fix
Fix git version when some head files are missing.
2012-08-22 16:54:17 -07:00
Pepe Barbe
5c4a523148 fix _gitinfo function to avoid ansible crashing in cases where the branch file is missing (e.g. after a gc) 2012-08-22 13:54:25 -05:00
Michael DeHaan
2833f48ed3 Make a particular error about an invalid include statement a bit clearer. 2012-08-21 22:08:08 -04:00
Michael DeHaan
3de4e45741 Move plugin directories 2012-08-21 20:32:21 -04:00
Michael DeHaan
bf92a9e4e0 Store invocation differently from an API perspective, but hide in callbacks 2012-08-20 20:41:53 -04:00
Dave Peticolas
4b4bcdedc1 Fix off-by-one serial count (causing infinite loop for serial == 1). 2012-08-21 13:43:05 -07:00
Grzegorz Nosek
94f56614e7 Fix UTF-8 output when using executable inventory files
The 'hostname' variable is then unicode, which breaks interpolating
stdout etc. contents into the output strings (they are bytes and cannot
be converted to Unicode using ASCII codec)
2012-08-20 18:26:21 -04:00
Grzegorz Nosek
73b0dd4ac0 Enable UTF-8 commands via the raw module
Paramiko does not allow Unicode strings as parameters, so encode
the command to UTF-8.

Test case:

ansible localhost -m raw -a 'echo ą'

(also tested on local and ssh transports without problems)
2012-08-20 18:26:21 -04:00
Grzegorz Nosek
2aef0335cb Handle UTF-8 in templates
This is required to run commands containing non-ASCII characters, e.g.:

ansible localhost -m shell -a 'echo ą'
2012-08-20 18:26:21 -04:00
Tim Bielawa
4121109665 Local actions, they're like aliases for actions with localhost
delegates.

Closes #905
2012-08-20 18:26:21 -04:00
Michael DeHaan
6e79555621 remove stray imports 2012-08-18 20:38:47 -04:00
Michael DeHaan
3cbf885079 Change the order the setup cache is used to update things, such that the example/playbooks/conditional_part1.yml file
works as advertised
2012-08-18 19:49:49 -04:00
Michael DeHaan
3017dc92d9 make callbacks modular 2012-08-18 19:43:08 -04:00
Michael DeHaan
7fd4051857 make connection types pluggable 2012-08-18 10:52:24 -04:00
Michael DeHaan
898d7676f7 Adds the 'serial' keyword to a playbook which controls how many hosts can be running through a playbook at a single time.
The default is 0, which means all hosts.  If set to 1, each host would run a playbook all the way through before moving
on the next host.  Fact gathering is still parallel, regardless of the serial setting.
2012-08-18 09:52:13 -04:00
Michael DeHaan
e13c33bb86 Moved Runner's ReturnData class to a seperate file. 2012-08-18 09:30:33 -04:00
Michael DeHaan
f07e55c568 Adds 'delegate_to' as a task option which can be used to signal load balancers and outage windows. 2012-08-18 08:46:51 -04:00
Pepe Barbe
e4a2de4f82 Syntax changes necessary to make test-module work with Python 2.4 2012-08-17 10:35:17 -05:00
Michael DeHaan
fe923b9394 Adaptation of fix in #891 to avoid cut on only one md5 call. 2012-08-16 22:45:43 -04:00
Michael DeHaan
5bb5082ed9 Fix failed to parse message handling 2012-08-16 21:47:17 -04:00
Michael DeHaan
0579b8b4e6 The command module was not reporting on errors like the other modules when the module failed
to parse or return other valid output.  This is a slight improvement.
2012-08-16 21:44:59 -04:00
Michael DeHaan
eee2d1afd0 If ANSIBLE_KEEP_REMOTE_FILES=1 is set as an environment file, remote files will not be deleted, which is useful only for development debugging purposes. 2012-08-16 21:34:55 -04:00
Michael DeHaan
de221e6b4b Add vars to host_vars to prevent some suprises 2012-08-14 20:35:01 -04:00
Michael DeHaan
9851066f4d Adding ability to set ssh args from config file 2012-08-14 20:13:02 -04:00
Michael DeHaan
6de8c27085 Load parent groups when processing group_vars 2012-08-14 19:48:33 -04:00
Michael DeHaan
7d50a5c2b7 Merge pull request #865 from jdavisp3/vars-file
Always load group_vars and host_vars.
2012-08-14 04:55:18 -07:00
willthames
c01040ca72 Further fixes for constants following config introduction
Added an ANSIBLE_CONFIG variable to poteentially override
~/.ansible.cfg
Used os.path.expanduser against all paths that might be read in to allow
~ to be used in config files. I'd have preferred it if os.path.expanduser
took None as an argument but it doesn't.

If remote_port *is* set in the ansible config file, then it will be
interpreted as a string (at which point ssh.connect fails with an
obscure message). Most other numeric variables are handled by
the OptionsParser which takes a type variable when setting up the option -
but remote_port is not an option, so never cast to int.

It might be worth adding a type field to get_config that defaults to a string.
That could be e.g. file or int, which then casts it correctly.
2012-08-14 20:22:47 +10:00
Dave Peticolas
b42e835aab Always load group_vars and host_vars. 2012-08-13 21:08:05 -07:00
Michael DeHaan
7ab0d60b1a update config code 2012-08-13 20:17:07 -04:00
Michael DeHaan
62fbbf7653 config file support 2012-08-13 19:17:59 -04:00
Michael DeHaan
00c28e2810 formatting 2012-08-11 18:41:36 -04:00
Michael DeHaan
1e4d45af1e Add module common code to allow it to be easier to indicate whether arguments are mutually exclusive, required in conjunction, or whether one of a list of arguments is required. This simplifies writing Python modules. 2012-08-11 18:13:29 -04:00
Michael DeHaan
deec50fc3c Default -u (user) and "user:" in playbooks to the current user. 2012-08-11 17:33:34 -04:00
Michael DeHaan
3587ffdef3 Allow /bin/ansible to use --limit 2012-08-11 14:05:24 -04:00
Michael DeHaan
9041adddaa Add support for ranged patterns like webservers[0-49] for hitting the first 50 webservers. 2012-08-11 13:49:18 -04:00
Michael DeHaan
72faf8eb0a fix indents 2012-08-11 12:20:16 -04:00
Michael DeHaan
301edb5b52 use StringIO for output concatenation, minor other tweaks to previous commit 2012-08-11 11:59:14 -04:00
Michael DeHaan
3cc564c127 Merge branch 'devel' of https://github.com/SleeplessAnnoyedNerd/ansible into devel 2012-08-11 11:48:57 -04:00
Michael DeHaan
d1ad1d2508 remove stray print 2012-08-11 11:41:40 -04:00
Michael DeHaan
259f2dc4de Various retooling of the internal code behind inventory pattern matching in support of pending support
for host ranges.
2012-08-11 11:36:59 -04:00
Dietmar Schinnerl
ac44c36e4f Removed unnecessary string replacements since parse_json already filters garbage lines 2012-08-11 16:57:04 +02:00
Dietmar Schinnerl
6b622beb4d Added filtering of non-JSON lines. 2012-08-11 16:24:16 +02:00
Dietmar Schinnerl
fbdddc7c74 Added utils.last_non_blank_line 2012-08-11 16:14:19 +02:00
Dietmar Schinnerl
993bb5c6f1 Added stub implementation of filters 2012-08-11 15:55:14 +02:00
Dietmar Schinnerl
bfed87df80 Removed leading blanks 2012-08-11 15:49:00 +02:00
Dietmar Schinnerl
6a18075640 Issue #848: Closing stdin after we read from stdout 2012-08-11 15:13:07 +02:00
Michael DeHaan
1c81ddf8d4 add the limit option, which can be used to further confine the patterns selected by "hosts:" in ansible-playbooks
to an additional pattern (a subset) specified on the command line.  For instance, a playbook could be reusable
and target "webservers" and "dbservers", but you want to test only in the stage environment, or a few boxes at a time.
2012-08-10 02:45:29 -04:00
Michael DeHaan
05a128c2be Add ability to store and access module results later on in the play. See examples/playbooks/register_logic for details. 2012-08-10 01:13:37 -04:00
Michael DeHaan
6c5761a79e Store the ${last_result} for each host to make it usable in only_if conditionals and such. 2012-08-10 00:58:53 -04:00
Michael DeHaan
c7888dd642 Given user report that EL5 sudo does not support '--', remove it, and things seem to still work fine.
let me know if this breaks any other boxes.
2012-08-10 00:15:23 -04:00
Michael DeHaan
02ba5a48e0 Merge branch 'cleanup-imports' of https://github.com/jdavisp3/ansible into devel 2012-08-10 00:05:04 -04:00
Michael DeHaan
a7415e5409 Merge pull request #836 from sfromm/rawfixes
Fixes for raw module usage and failure to open_session()
2012-08-10 17:01:47 -07:00
Sebastien Bocahu
a3ff6b1958 Fix unneeded bashism
Signed-off-by: Sebastien Bocahu <sebastien@ispfr.net>
2012-08-10 15:57:51 +02:00
Stephen Fromm
569d377183 Wrap paramiko open_session() call in try/except
Ran across non-unix host where the call to paramiko's open_session() in
exec_command() would throw a EOFError exception.  This change wraps the
block in a try/except.
2012-08-09 21:47:09 -07:00
Stephen Fromm
f9bdfde614 Fixes for runner and raw module
runner should not try to create or remove tmp paths when using the raw
module.
2012-08-09 21:45:00 -07:00
Dave Peticolas
08272dc25d Remove unused imports. 2012-08-09 21:35:22 -07:00
Michael DeHaan
05d6e74cce Merge branch 'vars_prompt_encrypt' of https://github.com/cocoy/ansible into devel 2012-08-09 21:41:12 -04:00
Michael DeHaan
07f459f3b2 Allow user to be passed in via --extra-vars 2012-08-09 21:14:30 -04:00
Michael DeHaan
98a5565106 Fixing up parameterized task includes such that variables can be easily handed to them. 2012-08-09 21:09:12 -04:00
Sundar Raman
2f754f0284 (Re #829) Fix for sudo_cmd not defined 2012-08-09 18:02:21 -04:00
Rodney Quillo
d1f821361d vars_prompt encrypt from mgw 2012-08-09 22:56:40 +08:00
Tim Bielawa
bf7e83bea6 Update man pages and the message for an exception. 2012-08-09 10:22:43 -04:00
Michael DeHaan
093bbd1c82 Slight version format tweaks 2012-08-08 21:23:33 -04:00
Michael DeHaan
e654f881a8 Merge pull request #812 from willthames/gitversion
Added commit time information to the --version output
2012-08-08 18:50:04 -07:00
willthames
208f2b66ed Added commit time information to the --version output
Now prints date of commit (and timezone offset of commit)
Hopefully resolves #783
2012-08-09 11:24:56 +10:00
Michael DeHaan
40ff3eb106 Catch socket errors so if you control-c a playbook it does not traceback 2012-08-08 21:19:20 -04:00
Michael DeHaan
85ba71a7fe Split -vv from -vvv 2012-08-08 21:16:48 -04:00
Michael DeHaan
cac4effd8f Add module arguments remote modules to -vvv output 2012-08-08 21:13:31 -04:00
Michael DeHaan
846186e2fc Add -vvv support for debugging activity 2012-08-08 21:09:14 -04:00
Michael DeHaan
c82f06258c Only run yum,apt through the with_items loop if there is a list of items. Just a cosmetic fix on return values
for the most part.
2012-08-08 20:43:01 -04:00
Michael DeHaan
2f6d6ccb5a Nicer errors from modules if arguments are not fed key=value 2012-08-08 20:30:20 -04:00
Michael DeHaan
183fce6d99 Detect SFTP disablement in paramiko + changelog updates 2012-08-08 20:27:33 -04:00
Michael DeHaan
51083e48e9 remove duplicate code path as few will have git python installed 2012-08-08 20:19:32 -04:00
Michael DeHaan
fde329fb9e Merge branch 'gitversion' of https://github.com/willthames/ansible into devel 2012-08-08 20:17:18 -04:00
Will Thames
9a50ed9b7b Added git information to version string
Running ansible --version now outputs git information when the
repo lives in .git in the root of the ansible source (coping with the case
where the git info is elsewhere is left as an exercise).

This uses gitpython where installed, otherwise it interrogates the files
in the .git directory to get the same information.

The gitpython path could be removed, but then people might ask 'why did
you do it like this when gitpython exists'
2012-08-09 10:12:04 +10:00
Michael DeHaan
176bf3cbb5 Save extra chmod step if sudoing to root 2012-08-08 19:17:31 -04:00
Will Thames
414eceb138 chmod needs more specific arguments to work with sudo_user
Basically if umask is set to something like 0007 then chmod +r and chmod +x
are not the same as chmod a+r and chmod a+x

Using os.path.basename rather than source.split should make ansible more
portable (and even if never ported, more readable)
2012-08-08 16:12:50 +10:00
Tim Bielawa
3937707117 Add 'polite' YAML syntax validation and hinting. Closes #798 2012-08-07 18:24:47 -04:00
Michael DeHaan
faed4b5a33 whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added
in 0.6 release)
2012-08-06 20:07:02 -04:00
Michael DeHaan
fd265b40b7 Release bump 2012-08-06 19:55:27 -04:00
Michael DeHaan
08c1f96e4b Fix some subtle behavior of how the get_url module chains into the file module, plus blend the results of daisy chain
operations in the correct order, so the file module results overlay the original module results, not the other way
around (which keeps any failure msg's intact)
2012-08-03 07:02:31 -04:00
Michael DeHaan
ce01c3f7e7 Allow unicode transfer by not base64 encoding. Also: faster 2012-08-02 21:20:43 -04:00
Michael DeHaan
227dfc17f3 fix tree output 2012-08-02 20:42:32 -04:00
Michael DeHaan
05df6464ef Make module args as unicode more or less not choke. 2012-08-02 20:29:18 -04:00
Michael DeHaan
b76efa39be Fix some templating issues, needs testing with anti-unicode safeguard around shlex.split 2012-08-02 20:21:59 -04:00
Seth Vidal
f924c96370 remove the tab I found
DIE TAB DIE
pep8
2012-08-02 17:26:04 -04:00
Michael DeHaan
c192d8a2b2 Revert "Apply templating to module arguments in playbook"
Breaks copy module by introducing unicodeness, among other things

This reverts commit 4fedb17e38.
2012-08-01 23:07:15 -04:00
Michael DeHaan
38ed7ca7df Merge pull request #759 from lorin/error-feedback
If task action is invalid, output the name in error message
2012-08-02 05:39:53 -07:00
Lorin Hochstein
aed6ee7f74 Report only name in task error, all on one line 2012-08-02 08:37:43 -04:00
Lorin Hochstein
fa9fe9d246 If task action is invalid, output the name and action. 2012-08-01 23:51:25 -04:00
Michael DeHaan
fe87a16a3e Make yum module use one-pass with with_items 2012-08-01 22:27:25 -04:00
Will Thames
4fedb17e38 Apply templating to module arguments in playbook
Module arguments should have variable substitution applied
Also, replacing task.action with the templated task.name seems wrong
2012-08-01 22:22:46 -04:00
Will Thames
d43d81a9a4 Raise exception when sudo user does not exist
sudo can fail before getting to the password prompt if a user does not exist
<pre>
[will@tangerine ansible (sudo_missing_user)]$ sudo -u bobbins echo hello
sudo: unknown user: bobbins
sudo: unable to initialize policy plugin
</pre>
Fix raises a distinct exception when that occurs
2012-08-02 16:19:15 +10:00
Michael DeHaan
25acfa8170 Join with_items for the apt module, yum pending, and various fixes to the yum module to support aliases 2012-08-01 20:33:13 -04:00
Michael DeHaan
86ec639176 add error handling if you try to load files in the wrong data format 2012-08-01 19:51:52 -04:00
Michael DeHaan
08c5fe875b yell if input data for host or group vars are not hashes 2012-08-01 19:46:33 -04:00
Michael DeHaan
ed14312ad6 reinstate invalid argument checks where possible, daisy chainee/chained modules turn it off 2012-08-01 19:42:31 -04:00
Petros Moisiadis
2ac4acbf97 fixes for tests 2012-08-01 22:17:16 +03:00
Petros Moisiadis
5f4bf813b1 added an 'ignore_errors' option to tasks
Failed tasks with ignore_errors=True, allow the remaining tasks in the
play to be executed as if no failure happened. A failure notice is still
written to the output as well as an '...ignoring' message.
2012-08-01 19:13:07 +03:00
Michael DeHaan
f60517aa33 temporarily disable failing check on some things 2012-08-01 09:33:20 -04:00
Ahmad Khayyat
6728b6cdda Allow = symbols in variable values in host inventory 2012-07-31 23:36:26 -04:00
Michael DeHaan
8700de964c Teach the common module code to warn users about typo'd arguments and also set everything to None automatically such
that code doesn't have to do a lot of params.get('foo', None) everywhere.
2012-07-31 21:23:34 -04:00
Timothy Appnel
b30f4688cd concatenating stdout and stderr in runner/__init__'s _low_level_exec_command. 2012-07-31 16:59:45 -04:00
u348095
7e279f972e Use sudo_user as an argument in the sudo command 2012-07-31 16:21:24 +10:00
Michael DeHaan
8e60ad986a Do not log login_password params to DB module 2012-07-30 21:21:30 -04:00
Michael DeHaan
da44fb1e43 Fixes #731 by reinstating variables for inventory scripts 2012-07-30 19:26:46 -04:00
Michael DeHaan
ff82f0a168 Further service module tweaks 2012-07-28 16:48:04 -04:00
Peter Sankauskas
0188889aea Making inventory pattern matching handle group names 2012-07-30 12:51:29 -07:00
Michael DeHaan
d0f0315c9d Merge pull request #723 from skvidal/devel
fix trace-creating error in apt module - also make the default setting a...
2012-07-30 10:45:42 -07:00
Seth Vidal
21a35bde00 new patch - adds a 'boolean' function to the module_common class and cleans up
the apt module to use it
2012-07-30 13:41:42 -04:00
Derek Carter
547395a2be added inventory_hostname_short varible 2012-07-30 13:26:48 -04:00
willthames
ad9b8e2312 Output version string when --version is passed using optparse's version argument 2012-07-30 14:19:02 +10:00
Michael DeHaan
17be5537d6 When sudoing to another user, the umask may be set such that the next user might not be able to read/execute
the file.  Deal with this.
2012-07-28 08:48:05 -04:00
Michael DeHaan
fcdc281c28 If sudoing to a user other than root, the home directory of the original user is very unlikely to be readable by the
sudoed to user, so just use tmp.  Data will be readable by others (briefly before deletion) but never writeable.
2012-07-27 20:53:50 -04:00
Michael DeHaan
aa40c5f3b3 remove commented out debug lines 2012-07-27 20:44:55 -04:00
Michael DeHaan
ee5f12cd40 Slight tweaks on vars_prompt upgrades 2012-07-27 19:00:48 -04:00
Petros Moisiadis
c717934b7e Improved 'vars_prompt' syntax to support prompt text and (non-)private input
An example of the new syntax:

vars_prompt:
 - name: 'secret_variable_name"
   prompt: "Enter secret value: "
   private: "yes"
 - name: "nonsecret_variable_name"
   prompt: "Enter non-secret value: "
   private: "no"
2012-07-27 19:00:48 -04:00
Michael DeHaan
a65b4fef97 Fix up chain invocations of template 2012-07-26 00:39:44 -04:00
Michael DeHaan
19fc8eea80 Things that happen inside multiprocessing shouldn't make side effects, ergo append ansible_facts only
in playbook code.

This technically means with_items calls can't continuously add facts I guess, but I can't see anyone
ever trying that.
2012-07-25 21:30:49 -04:00
Michael DeHaan
da4562f495 changes to not clear the setup cache between runs, and also decide to run plays with no tasks
in them if it looks like they are not tagged, because if that is the case, then we may just
be gathering facts about them.
2012-07-25 20:45:51 -04:00
Michael DeHaan
f371092845 rm stray comment 2012-07-25 20:31:57 -04:00
Michael DeHaan
e035ce97ce blue on black, tears on a river, push on a shove, it don't mean much
(make colorized playbook runs not suck on black terminals)
2012-07-25 20:31:26 -04:00
Lorin Hochstein
b63a3bd0c7 Save module name and args when processing list of items.
This is necessary because daisy-chained modules will overwrite
these values.
2012-07-25 13:26:07 -04:00
Michael DeHaan
8d7f526df6 importing/not-importing methods should be colorized 2012-07-24 20:41:24 -04:00
Michael DeHaan
d3e8e8ff54 Fix output message 2012-07-24 20:37:27 -04:00
Michael DeHaan
c16b691883 Copy module needs to use src as transfer path. 2012-07-24 20:35:10 -04:00
Michael DeHaan
263432daa1 Changed no hosts to red. Not sure this is the right color choice, but there is no orange :) 2012-07-24 20:21:49 -04:00
Michael DeHaan
82cca242e3 use AnsibleError so that if there is an error it does not print a traceback 2012-07-24 20:16:35 -04:00
Michael DeHaan
8fa4dc3920 Small change to previous patch, make ranges of hosts inclusive. 2012-07-24 20:10:05 -04:00
Michael DeHaan
416b8d59a9 Merge branch 'devel' of https://github.com/fangchin/ansible into devel 2012-07-24 19:57:51 -04:00
Michael DeHaan
15062b38e1 Fix typo 2012-07-24 19:50:16 -04:00
Michael DeHaan
12ff9b5b9a Move color coding bits to module, use over rest of playbook 2012-07-24 19:30:02 -04:00
Chin Fang
5315dd146d Added lib/ansible/inventory/expand_hosts.py 2012-07-24 12:43:35 -07:00
Chin Fang
e3b2521f01 Added a host expansion feature to ansible's inventory parsing 2012-07-24 12:38:52 -07:00
Jan-Piet Mens
44a9226ece file mode now correctly set after chaining from copy 2012-07-24 16:43:36 +02:00
Michael DeHaan
3a2df329af Tweak the way chained callbacks work 2012-07-23 22:12:26 -04:00
Michael DeHaan
dd6399b5ae Fixup args being passed into file from copy, tweak preservation of changed attribute. 2012-07-23 21:56:21 -04:00
Michael DeHaan
153f3932b5 reinstate delete_remote_files 2012-07-23 21:30:09 -04:00
Michael DeHaan
632a83c79e Remove unused function 2012-07-23 21:28:18 -04:00
Michael DeHaan
479f8b8c26 Templating neccessary here. 2012-07-23 21:10:16 -04:00
Michael DeHaan
9b8793e42e Fix a glitch with daisy chain logic 2012-07-23 21:01:59 -04:00
Michael DeHaan
183330a9fa Merge pull request #662 from tima/regex-cond-tasks
Importing re in runner for doing conditional tasks using pattern matching i.e. re.search(). Also conditionally outputting item when skipping.
2012-07-23 17:52:52 -07:00
Michael DeHaan
cbea17e4c5 Fix up async 2012-07-23 20:46:35 -04:00
Michael DeHaan
cac7afd700 async is under construction 2012-07-23 20:06:18 -04:00
Michael DeHaan
1f44c07ddf Fix assemble usage, some issues still with async. 2012-07-23 19:40:21 -04:00
Timothy Appnel
4b9b9a8a5b Importing re in runner for doing conditional tasks using pattern matching i.e. re.search(). Also conditionally outputting item when skipping. 2012-07-23 19:36:26 -04:00
Michael DeHaan
ec12cc4154 Save the transfer of the module file for new style modules, because we can inject the arguments into the modules.
Module consumers using the API don't have to know how this works.  base64 stuff is only there
because escaping a docstring inside a docstring was a bit of a challenge :)
2012-07-23 19:18:45 -04:00
Michael DeHaan
617f9dc942 Added some caching logic to improve external inventory scripts, removed some debug statements. 2012-07-22 11:53:19 -04:00
Michael DeHaan
57f12ac9e3 Using __slots__ in more places, in particular, hosts and groups, where we are apt to create a fair amount of objects. 2012-07-22 11:40:02 -04:00
Michael DeHaan
0b891fc8fb Tweaking daisychain internals to allow get_url to modify the path destination when downloading to a directory.
Minor module refactoring.
2012-07-22 11:08:16 -04:00
Michael DeHaan
396b81b647 Remove this check as it wasn't really needed and in recent refinements keeps the group_vars stuff from working
as desired.
2012-07-22 10:06:10 -04:00
Michael DeHaan
d0f4358730 Port the copy module over to the new "common module" logic. 2012-07-21 17:07:42 -04:00
Michael DeHaan
d76c8c9c85 Various cleanup around runner's constructor and how daisy chaining is invoked. 2012-07-21 16:51:31 -04:00
Michael DeHaan
1682dd06c0 Avoid duplicate call to fetch inventory variables 2012-07-21 16:23:00 -04:00
Michael DeHaan
54c9c1e25c Some streamlining of first_available_file code 2012-07-21 16:15:36 -04:00
Michael DeHaan
2d06ee4c0d Fix some subtle things that were keeping 'hostvars' from being usable in templates. 2012-07-20 12:34:26 -04:00
Michael DeHaan
2b6d8a8be5 Fix some issues with the setup cache 2012-07-20 11:58:08 -04:00
Michael DeHaan
5a67a556cd Script to migrate YAML users to the INI format, so we can deprecate YAML inventory (which we are now doing). 2012-07-20 11:15:57 -04:00
Michael DeHaan
dcca08b27b Don't let with_items erase 'hostvars' 2012-07-20 10:02:35 -04:00
Michael DeHaan
b574c70006 host and group vars should update the setup cache 2012-07-20 10:00:51 -04:00
Michael DeHaan
ba3466af95 The following paths are now implict and optional in vars_files:
./group_vars/groupname.yml (for all groups the host is in)
./host_vars/hostname.yml (for the hostname given in the inventory)

This requires an actual inventory file, not script and the paths are relative
to the directory of the inventory file.
2012-07-20 09:43:45 -04:00
Michael DeHaan
db1a4d8fac Make 'assemble' use the new daisychain logic 2012-07-20 09:17:42 -04:00
Michael DeHaan
6fb74ae2f9 preserve 'changed' attributes in daisychain logic 2012-07-20 09:13:10 -04:00
Michael DeHaan
d72c0c8898 replace module daisy-chaining logic 2012-07-20 08:57:50 -04:00
Michael DeHaan
6e84374c2a Make hostvars work post refactoring 2012-07-20 08:29:44 -04:00
Michael DeHaan
b0eedfbf92 Merge pull request #639 from goozbach/issue-627
improved output in with_items fixes: #627
2012-07-20 16:36:49 -07:00
Michael DeHaan
85b9fa580c Merge pull request #644 from bradobro/common_fix
AnsibleModule now correctly reads param values with '"'.
2012-07-20 14:31:24 -07:00
bradobro
a4a09fec82 AnsibleModule (in module_common.py) now correctly reads param values containing '='. 2012-07-20 21:19:38 +00:00
Stephen Fromm
8195375412 Sanitize possible password argument when logging invocation; taken from user module 2012-07-20 11:57:36 -07:00
Derek Carter
34e2584220 improved output in with_items fixes: #627 2012-07-20 14:01:54 -04:00
Rodney Quillo
5f068913ee Suppress Ubuntu ssh -tt error ioctl error. 2012-07-20 13:23:14 +08:00
Michael DeHaan
a94ec130d2 Common module code upgrades 2012-07-17 23:09:57 -04:00
Michael DeHaan
9006d4557d Added code to allow insertion of boilerplate into modules to make them able to share lots of code, the result
should be a huge reduction of total ansible source, at a slight cost of difficulty in original module development.

We need to apply this now to all modules, but may need to have some exemptions to things like command, which should
subclass this module.
2012-07-17 22:34:52 -04:00
Peter Sankauskas
4b66d98332 Adding missing colon... can't believe I missed that... sorry 2012-07-18 17:48:13 -07:00
Michael DeHaan
b38f8bfa80 Merge pull request #620 from pas256/patch-1
Conditional Imports should only import the first vars_file found in list
2012-07-18 16:31:45 -07:00
Peter Sankauskas
413fb15e0a Conditional Imports should only import the first file in the list, not all of them. This change stops looping through the vars_files list as soon as a file is found. 2012-07-18 15:31:04 -07:00
Seth Vidal
5ad9bc8833 when using -i"hostname," on the cli - don't complain about the host named "" not being a host - just clip it from the list 2012-07-18 16:56:41 -04:00
Michael DeHaan
bfed0f14ec Merge pull request #613 from ludovicc/devel
Allow local plays to execute when --ask-sudo-pass is used on the command line
2012-07-18 10:27:51 -07:00
Ludovic Claude
26dc607c5c Revert "Change previous fix to a one line change relative to upstream"
This reverts commit 0d53b1b097.
2012-07-18 19:02:56 +02:00
Ludovic Claude
0d53b1b097 Change previous fix to a one line change relative to upstream 2012-07-18 17:52:51 +02:00
Ludovic Claude
c4303c8c04 Avoid spurious error when mixing a local play with remote plays depending on --ask-sudo-pass 2012-07-18 12:05:12 +02:00
Jeroen Hoekx
f1b1611956 Fix typo while handling custom facts.
This fixes #611.
2012-07-18 11:50:34 +02:00
Michael DeHaan
8bb8314d10 Inject vars need to pushed further up to make with_items work as desired. 2012-07-17 20:09:18 -04:00
Michael DeHaan
3c2cbae68e Plays and tasks now yell when they see parameters they do not understand, so that typos like 'var' for 'vars'
don't result in people having to ask questions about what is wrong with their playbook
2012-07-17 19:09:36 -04:00
Michael DeHaan
e4a546e8bb Make it possible to use variables from 'vars' in the paths to task level include statements. 2012-07-17 18:57:02 -04:00
Dave Hatton
72ca9e58e7 meaningful messages if the remote md5 fails 2012-07-17 09:14:16 +01:00
Michael DeHaan
0edd0d4736 Fixing template calls 2012-07-16 20:26:39 -04:00
Michael DeHaan
5f69c557b9 Fix for the way host variables were being swallowed, plus some overall simplification. Deciding what
dictionary to use for templating now happens in exactly one place (executor_internal) and the "inject"
dictionary is passed to what needs it.
2012-07-15 14:19:11 -04:00
Dave Hatton
c3205595b3 format fixes to make fetch more usable 2012-07-16 11:43:37 +01:00
Michael DeHaan
b542dd8466 Fix import in ssh connection 2012-07-15 13:12:11 -04:00
Michael DeHaan
80edea2934 with_items handling code should apply to all modules, was screwed up in refactoring to only apply to 'normal'
modules.
2012-07-15 12:51:56 -04:00
Michael DeHaan
1754de3335 Misc code cleanup, mostly whitespace preferences, removing unused imports, plus a few fixes here and there. 2012-07-15 12:29:53 -04:00
Michael DeHaan
4b73931351 misc code cleanup, don't pass parameters to the connection object we can already get from Runner 2012-07-15 11:54:39 -04:00
Michael DeHaan
6341e75e33 misc code cleanup 2012-07-15 11:20:59 -04:00
Michael DeHaan
031ba43d22 minor code cleanup 2012-07-15 11:09:15 -04:00
Michael DeHaan
1d8bb17785 misc code cleanup 2012-07-15 10:57:22 -04:00
Michael DeHaan
5a63a48e6b No need to feed variables into the setup module for preservation since the file is no longer saved to disk. 2012-07-15 10:24:38 -04:00
Michael DeHaan
227c500ad7 Misc cleanup/formatting 2012-07-15 10:22:15 -04:00
Michael DeHaan
867b2437cc consolidate output code in callbacks.py, from utils, remove extra functions 2012-07-15 10:12:49 -04:00
Michael DeHaan
bc71c6ddd7 add space between function 2012-07-15 09:33:48 -04:00
Michael DeHaan
cb55cd6f8d removed unused function 2012-07-15 09:33:22 -04:00
Michael DeHaan
68a9adc1be Indentation cleanup (partial) 2012-07-15 09:32:47 -04:00
Michael DeHaan
244b923559 No longer need to calculate setup metadata location since we don't write
the setup file to disk.
2012-07-15 09:25:17 -04:00
Michael DeHaan
61d8e2e7c7 with_items should be processed inside the task class, also make first_available_file
and with_items incompatible.  Most cases that would need this could be solved
with vars_files.
2012-07-15 09:17:04 -04:00
Michael DeHaan
706cfd9ade Misc cleanup -- moved function out of utils, removed debug statement. 2012-07-15 08:50:23 -04:00
Michael DeHaan
19a2fc00dc Clean up imports in utils, add nicer recursion depth limit check. 2012-07-15 08:46:58 -04:00
Michael DeHaan
60d64251f8 Allow gather_facts: False in a playbook as a way of disabling the fact step if you know
you aren't going to need it.
2012-07-14 19:49:42 -04:00
Michael DeHaan
64c51ade1e Change the way we do with_items to make them happen next to each other in runner, which eliminates the problem of with_items and vars_files sometimes not playing nice with each other.
(Also a fix for the user module error handling when the user
is not present at the time of the return.  This can only really be caused by multiple ansible executions).
2012-07-14 19:18:33 -04:00
Michael DeHaan
028f216689 Error handling and magic around with_items, to let you know when variables are usable inside it and when not. 2012-07-14 13:23:14 -04:00
Michael DeHaan
102b22be1f Make the logic behind vars_files smarter, so host specific vars go into the setup cache, but other variables
are usable top level.  This allows vars_files data to be used, most of the time, just fine in with_items,
(error handling pending) but is mostly a memory and efficiency thing.
2012-07-14 13:12:19 -04:00
Michael DeHaan
15b2b3a020 Warn if something loaded by vars_files is not a dictionary 2012-07-14 12:39:06 -04:00
Michael DeHaan
279b5965b8 Much streamlining around setup steps in playbooks, now only run setup once per play. 2012-07-14 12:24:19 -04:00
Michael DeHaan
931f9f1a61 Setup module no longer saves to disk, as templates are mostly useful in playbooks and this allows lots of simplifications
around file pathing and removes occasional permissions conflicts depending on how things are used.
2012-07-14 11:59:12 -04:00
Michael DeHaan
60f295f7a0 Squashed commit of the following:
commit 4430ce3eefcdff0b0ceffea0ef66ea8e876a807d
Merge: 631783b 649963c
Author: Michael DeHaan <michael.dehaan@gmail.com>
Date:   Thu Jul 12 01:28:43 2012 -0400

    Merge branch 'host-groups' of https://github.com/dagwieers/ansible into daggroups

commit 649963ca2c
Author: Dag Wieërs <dag@wieers.com>
Date:   Thu Jul 12 23:01:00 2012 +0200

    Added comments in the example yaml file as requested

commit 7f9718f185
Author: Dag Wieërs <dag@wieers.com>
Date:   Thu Jul 12 22:49:38 2012 +0200

    Add the default nose color too, to test specific overrides

commit eb63b9e899
Author: Dag Wieërs <dag@wieers.com>
Date:   Thu Jul 12 22:44:35 2012 +0200

    Introduce comics and cartoons to test yaml groups defined on a per-node basis

commit aa13d23307
Author: Dag Wieërs <dag@wieers.com>
Date:   Thu Jul 12 19:33:15 2012 +0200

    A small fix to revert to old state

commit 264ebaa77c
Author: Dag Wieërs <dag@wieers.com>
Date:   Thu Jul 12 19:31:51 2012 +0200

    Combine both yaml unit tests into one example file

commit 7db49a8048
Author: Dag Wieërs <dag@wieers.com>
Date:   Thu Jul 12 16:46:53 2012 +0200

    Might as well fix this too

commit f36c6c8c5b
Author: Dag Wieërs <dag@wieers.com>
Date:   Thu Jul 12 16:42:00 2012 +0200

    Added unit tests for host-groups patch

    For the unit test I chose to keep the original yaml file in place as a reference.

    This patch also includes a fix.

commit a96f681352
Author: Dag Wieërs <dag@wieers.com>
Date:   Thu Jul 12 12:30:43 2012 +0200

    Allow groups to be defined on a per-host basis

    This makes it possible to define on a per-host basis what groups a host is in.
    When managing a large set of systems it makes it easier to ensure each of the
    systems is defined in a set of groups (e.g. production/qa/development,
    linux/solaris/aix) rather than having to add systems to multiple disconnected
    groups.

    ----
      - host: system01

      - host: system02

      - host: system03

      - group: linux
        hosts:
        - system01
        - system02

      - group: solaris
        hosts:
        - system03

      - group: production
        hosts:
        - system01
        - system03

      - group: qa
        - system02

      - group: dbserver
        hosts:
        - system01

      - group: ntpserver
        hosts:
        - system02

      - group: webserver
        - system03
    ----

    Can be redefined as:

    ----
      - host: system01
        groups: [ linux, production, dbserver ]

      - host: system02
        groups: [ linux, qa, ntpserver ]

      - host: system03
        groups: [ solaris, production, webserver ]
    ----
2012-07-12 01:29:51 -04:00
Michael DeHaan
611e5b0c90 Make adding tags to a playbook work as shorthand to tagging all tasks in the play. 2012-07-12 00:58:48 -04:00
Michael DeHaan
cf313cde96 Soft import of paramiko since we have the SSH and local connection types now. Packaging will still
require it.
2012-07-12 00:43:51 -04:00
Michael DeHaan
a765deccce Allow top level playbook files to import other playbook files, added some basic
playbook structure checking.
2012-07-12 00:19:44 -04:00
Dag Wieërs
cb40778b84 Wrong evaluation of a local file before fetching the remote file 2012-07-13 11:07:32 +02:00
Timothy Appnel
84fa9dcaee The default private key file was getting set incorrectly from environment variables. My bad. 2012-07-12 13:30:30 -04:00
Ingo Gottwald
26aa4e2469 Enabled cowsay support for Ubuntu 2012-07-12 11:14:15 +02:00
Michael DeHaan
dc4ebab345 Merge pull request #576 from davehatton/adjust_playbook_output_formating
improve output formating for playbook
2012-07-11 17:42:39 -07:00
Michael DeHaan
969c3feb13 Allow include statements from plays to specify tags (see tags.yml example file).
Also be smart and don't run a play at all if no tasks in the play match any of the tags specified.  This includes not running the setup actions!
2012-07-11 20:33:46 -04:00
Michael DeHaan
83f23ef861 Basic support for tagging tasks and selecting a subset of tasks to run with --tags. 2012-07-11 19:51:26 -04:00
Dave Hatton
7ecdb83800 improve output formating for playbook 2012-07-11 09:35:10 +01:00
John Kleint
375a1eaf43 Use iterative MD5 hashing. 2012-07-09 13:27:47 -04:00
Dave Hatton
55694db7c3 switch to hashlib.md5 or md5 instead of OS md5 commands 2012-07-09 08:52:00 +01:00
Michael DeHaan
0d28466b22 When sudo'ing to root, keep the setup file location as /etc/ansible/setup 2012-07-07 09:29:03 -04:00
Michael DeHaan
c2b8fabf66 Take a remote md5sum before a file transfer to decide whether to transfer the file or not.
Allows for efficient transfer of large files.  Templates do not sample first because they are small.
2012-07-07 09:10:18 -04:00
Michael DeHaan
8220d57690 Clean up md5 functions + make the fetch module stay happy if the remote file does not exist. 2012-07-07 08:47:32 -04:00
Michael DeHaan
b551eba6d4 Comment uncommented methods in utils 2012-07-07 08:47:32 -04:00
Michael DeHaan
a490213d45 Release bump to start development on 0.6 2012-07-04 18:07:19 -04:00
Michael DeHaan
e3aba7770f Merge pull request #518 from brainpage/devel
adds 'groups' variable, essentially making hosts file accessible as a var
2012-07-04 11:28:46 -07:00
Daniel Hokka Zakrisson
9882dd56f6 Allow variables in variables in templates 2012-07-03 16:42:00 +02:00
alex
f72b1f4fd7 Fixed: pathname for tmp 2012-07-02 22:04:56 +02:00
alex
bbf2939063 Fixed: executing templates outside playbooks 2012-07-02 21:34:11 +02:00
Jonathan Palley
cedbcfcc0a adds 'groups' variable, essentially making hosts file accessible as a variable 2012-07-01 15:04:53 +08:00
Michael DeHaan
a5dd280149 Fix up the output of the raw module when run within /usr/bin/ansible 2012-06-29 18:48:37 -04:00
Michael DeHaan
efac68b636 Remove the -D module debug flag, which no longer is functional due to sudo pty requirements, and replace with -v/--verbose.
This flag will show playbook output from non-failing commands.  -v is also added to /usr/bin/ansible, but not  yet used.

I also gutted some internals code dealing with 'invocations' which allowed the callback to know what module invoked
it.  This is not something 0.5 does or needed, so callbacks have been simplified.
2012-06-19 21:57:43 -04:00
Jeroen Hoekx
d592e15dcc Correctly add ungrouped hosts to 'ungrouped' in YAML inventory. 2012-06-27 08:26:01 +02:00
Michael DeHaan
afb2e3e5ac Merge pull request #511 from dsummersl/devel
added ability to ovverride all ssh settings via ANSIBLE_SSH_ARGS
2012-06-26 15:28:49 -07:00
Dane Summers
37fce9c0f6 added ability to ovverride all ssh settings via ANSIBLE_SSH_ARGS 2012-06-26 14:59:42 -04:00
Michael DeHaan
8468e2255b Merge pull request #507 from jhoekx/convention-library-path
Add ./library to module search path.
2012-06-25 12:20:56 -07:00
Jeroen Hoekx
879ddddf6f Add ./library to module search path.
It allows for custom modules in the best practices directory structure.
Bundling custom modules along with playbooks in packages is useful.
2012-06-25 21:08:43 +02:00
Jeroen Hoekx
6c92d2fa88 Import ansible errors in Poller. 2012-06-25 20:48:35 +02:00
Michael DeHaan
618924a24f Merge pull request #497 from davehatton/change_constants
shouldn't need a (slash) before /home/daveh
2012-06-22 12:01:15 -07:00
Dave Hatton
d42df3a82e change to STDOUT from PIPE to get ssh connection module working 2012-06-22 12:37:23 +01:00
Dave Hatton
d28bbe14ed shouldn't need a (slash) before /home/daveh 2012-06-21 15:37:43 +01:00
Dave Hatton
30d4f070a1 change STDOUT to PIPE to get ssh connection module working 2012-06-21 11:01:08 +01:00
Daniel Hokka Zakrisson
fa887bc90f Merge stdout and stderr for non-sudo 2012-06-20 20:49:52 +02:00
Daniel Hokka Zakrisson
7884bc02ea Wait for process to finish and then parse output 2012-06-20 20:49:52 +02:00
Seth Vidal
dca75033fe add -q to handle stdout/stderr being combined, add catch for ControlPersist not existing in ssh for rhel6, etc 2012-06-20 14:06:24 -04:00
Michael DeHaan
9662902c31 Merge pull request #492 from dhozac/unnecessary-parse_json
Remove unnecessary parse_json invocation
2012-06-20 10:26:17 -07:00
Michael DeHaan
071978a2e7 Merge pull request #493 from dhozac/ssh-merge-stdouterr
Merge stdout and stderr as that is what is expected
2012-06-20 10:24:32 -07:00
Daniel Hokka Zakrisson
f5ecd075f7 Remove unnecessary parse_json invocation 2012-06-20 14:54:36 +02:00
Michael DeHaan
bd653c8f3c Merge pull request #488 from dhozac/jinja2-env
Create a Jinja2 environment allowing includes
2012-06-19 13:09:02 -07:00
Michael DeHaan
e0f12292d8 Merge pull request #489 from dhozac/ssh-args-default
Default to using a ControlMaster connection
2012-06-19 13:01:09 -07:00
Daniel Hokka Zakrisson
7f6359b143 Default to using a ControlMaster connection 2012-06-19 21:58:24 +02:00
Daniel Hokka Zakrisson
d08ba12a42 Merge stdout and stderr as that is what is expected
Should also fix problems where something might output an error
before the sudo prompt.
2012-06-19 21:55:00 +02:00
Seth Vidal
1ec518543e make Runner options conflict errors raise AnsibleErrors not traceback in general
add catch if -c ssh and -k are passed at the same time since the ssh connection type doesn't
support passwords
2012-06-18 15:48:19 -04:00
Daniel Hokka Zakrisson
9f93839d13 Create a Jinja2 environment allowing includes 2012-06-17 22:18:08 +02:00
Daniel Hokka Zakrisson
ab08fea1aa Add an ssh command wrapper transport 2012-06-17 20:34:17 +02:00
Daniel Hokka Zakrisson
13b814a33c Run templating function until the text doesn't change
This allows variables to contain other variables.
2012-06-16 12:51:19 +02:00
Michael DeHaan
dad9695ac7 Merge pull request #478 from dhozac/not-host
Allow exclusion of hosts/groups
2012-06-15 17:39:47 -07:00
Jonte Norman
1b091a7e3e Fixed typo from results to result in _execute_raw method 2012-06-15 22:45:47 +02:00
Daniel Hokka Zakrisson
3d5c93bf44 Allow exclusion of hosts/groups 2012-06-15 11:01:30 +02:00
Fred Alger
834f6a216d Make shell outs to md5sum work on FreeBSD and OS X
Tested with OS X local connection and Linux remote. The paths to the
md5sum and md5 commands are hardcoded to the most common location. This
will definitely fail if the commands are elsewhere, or if the md5
command doesn't support the -q 'quiet' option.
2012-06-15 00:04:01 -04:00
Michael DeHaan
c0a5d91592 Merge pull request #475 from nafeger/devel
Better error messaging in utils
2012-06-14 12:15:36 -07:00
Nathan A. Feger
9feb26ab28 Better error messaging in utils
When a command responds with json that is unparseable, dump that unpareseable response instead of swallowing it.
2012-06-14 13:17:38 -05:00
Michael DeHaan
2a8d1f07d4 Merge branch 'mktemp-vanish' of https://github.com/dagwieers/ansible into devel
Conflicts:
	lib/ansible/runner/__init__.py
2012-06-13 22:39:58 -04:00
Michael DeHaan
27c949ade9 Merge pull request #462 from tima/more-env-defaults
Most constants can be overriden with environment variables.
2012-06-13 19:20:33 -07:00
Michael DeHaan
2a49438c37 Merge pull request #461 from dhozac/only_if-early
Evaluate only_if early
2012-06-13 19:19:25 -07:00
Michael DeHaan
bd893b765b Merge pull request #459 from dhozac/with_items-variable
Allow a variable in with_items
2012-06-13 19:18:51 -07:00
Stephen Fromm
9cf182c225 Add assemble module
This adds a module that concatenates (ie. assembles) a file from
fragments in a directory in alphabetical order.  It chains the file
module afterward to fix up ownership and permission.  This also adds
tests for the assemble module with fragments in assemble.d.
2012-06-11 23:09:54 -07:00
Timothy Appnel
5ea8ad2d94 Most constants can be overriden with environment variables. Reserved doing anything with the connection options for further review. 2012-06-11 18:07:44 -04:00
Daniel Hokka Zakrisson
7942570411 Fix on_unreachable invocation with non-existing variable 2012-06-11 15:15:29 +02:00
Daniel Hokka Zakrisson
eba81ee36f Evaluate only_if early to do as little work as possible 2012-06-11 15:15:29 +02:00
Matt Goodall
c1b38f62c8 Search multiple paths for modules.
Minimal change to allow a list of paths (separated by the typical path
separator) to be searched in sequence for the named module.
2012-06-10 16:22:59 +01:00
Daniel Hokka Zakrisson
a05da2d312 Allow with_items to specify a variable 2012-06-09 21:59:22 +02:00
Daniel Hokka Zakrisson
933b5e8631 Reduce code duplication 2012-06-09 21:50:46 +02:00
Michael DeHaan
e8e6c98016 Merge pull request #455 from dhozac/vars_files-non-list
Expand vars_files identically for lists and non-lists
2012-06-08 12:19:47 -07:00
Michael DeHaan
01387520e9 Merge pull request #451 from phred/fix-fetch-module
Make 'fetch' test for local directories before creating.  Fixes issue #450
2012-06-08 12:06:02 -07:00
Michael DeHaan
e265cdfa1d Merge pull request #454 from jhoekx/configure-python-interpreter
Introduce ansible_python_interpreter variable.
2012-06-08 12:03:40 -07:00
Michael DeHaan
b1c2820a32 Merge pull request #456 from dhozac/notify-variable
Allow variables in notify list
2012-06-08 11:59:39 -07:00
Daniel Hokka Zakrisson
d0d036fd3f Expand $item for copy and fetch 2012-06-08 01:36:52 +02:00
Daniel Hokka Zakrisson
ad7b744764 Allow variables in notify list 2012-06-08 01:35:23 +02:00
Daniel Hokka Zakrisson
dff8d7be04 Expand vars_files identically for lists and non-lists 2012-06-08 01:32:56 +02:00
Jeroen Hoekx
1f63c47738 Introduce ansible_python_interpreter variable.
This allows configuration of the correct python interpreter on the managed system.
2012-06-07 09:50:38 +02:00
Dag Wieërs
b3b22c41e9 Get rid of mktemp dependency to support AIX
The function call has been renamed to better reflect what it does, and we
reduced the number of calls from two to one in case the remote user is not
root.

This patch also fixes a string concatenation in _copy_module() that
should use os.path.join() instead.

This closes #436
2012-06-06 14:47:47 +02:00
Fred Alger
bee04de26a Fix exception in fetch module when src or dest parameter omitted. 2012-06-05 11:35:19 -04:00
Fred Alger
d0c4f4015c Fix remote md5 in fetch module, related to Issue #450 2012-06-05 11:35:19 -04:00
Fred Alger
51b460e8c6 Make 'fetch' test for local directories before creating. Fixes issue #450 2012-06-05 10:38:12 -04:00
John Kleint
e9f770fa11 More helpful message when ssh fails. 2012-06-01 17:16:02 -04:00
Michael DeHaan
1ee7ff2f7b To allow plays using different user accounts in the same playbook to function, clear the setup cache
between plays.
2012-05-31 22:08:00 -04:00
Michael DeHaan
16f0d7b333 Revert "Get rid of mktemp dependency to support AIX"
This reverts commit 4ad1b57b52.
2012-05-31 21:59:31 -04:00
Michael DeHaan
99430fa0a3 Fix for older version of sudo + some changes to imports so tests are happy 2012-05-31 21:44:56 -04:00
Michael DeHaan
634cf9aaba Merge pull request #437 from dagwieers/mktemp-vanish
Get rid of mktemp dependency to support AIX
2012-05-31 18:37:28 -07:00
John Kleint
70837469c6 Properly template list of hosts in playbooks.
In playbooks, hosts can be a YAML list. We templated the list before
converting it to a semicolon-separated string, which actually templated its
repr. This converts to a string first. A basic unit test is included.
2012-05-31 16:06:21 -04:00
Dag Wieers
a8fd6ee9c3 Get rid of mktemp dependency to support AIX
The function call has been renamed to better reflect what it does, and we
reduced the number of calls from two to one in case the remote user is not
root.

This patch also fixes a string concatenation in _copy_module() that
should use os.path.join()

This closes #436
2012-05-31 17:02:10 +02:00
Michael DeHaan
6034b5b0f3 Split connection code into submodules. 2012-05-30 20:16:31 -04:00
Michael DeHaan
0972b761de Leverage cowsay if installed. 2012-05-30 19:44:00 -04:00
Brad Olson
c34921fe7b Removed legacy comment. 2012-05-30 15:37:14 -04:00
Brad Olson
81591009ea Fixed Inventory.get_hosts() ignoring restriction when there are no hosts left.
get_hosts() was treating [] (meaning complete restriction, no hosts allowed)
the same as None (meaning no restriction, all hosts allowed). Fixed logic.
2012-05-30 15:34:21 -04:00
Michael DeHaan
af9651f015 Merge pull request #420 from bradobro/fix_no_varfiles
Test for play.vars_files == None, avoiding nasty traceback.
2012-05-29 08:32:47 -07:00
Brad Olson
7ea4a0e895 Avoid traceback when vars file has no vars items. Could warn or fail instead. 2012-05-29 10:23:09 -04:00
Brad Olson
32b9ea689a Test for play.vars_files == None, avoiding nasty traceback. Ignores for now. Could warn.
Playbook test for no vars_files with len(), but that excepts if play.vars_files==None, as can happen when there's a vars_files section with no vars files listed. What is the ansible way: ignore, warn, or fail with message (instead of traceback)?
2012-05-29 10:09:38 -04:00
Cosmin Luță
74bfd7eb81 Removed line that caused stacktrace 2012-05-27 14:15:30 +03:00
Michael DeHaan
4664e354c3 Get with_items to work with new play/task architecture. 2012-05-26 01:49:23 -04:00
Michael DeHaan
ecb944892d Tweaks on previous refactoring of playbook, version bump a 0.4 reference, remove some debug, etc 2012-05-26 01:20:53 -04:00
Michael DeHaan
b9b53d1941 Playbook refactoring -- work in progress. 2012-05-26 00:37:34 -04:00
Michael DeHaan
cf9ddf3a30 Reorganizing file structure. Not done. 2012-05-25 19:34:13 -04:00
Michael DeHaan
6f114a2e2c Delete poller code from runner.py now that it is moved. 2012-05-25 19:20:01 -04:00
Michael DeHaan
db1d5b154a Fix casing/underscore convention in method name, split polling logic away from runner. 2012-05-25 19:18:02 -04:00
Michael DeHaan
6d580aea02 As part of a precursor to other refactoring, make returns less list-like throughout runner. 2012-05-25 18:44:29 -04:00
Matt Goodall
639763c138 Allow "=" in k-v values. 2012-05-23 00:58:05 +01:00
Matthew Williams
7bbcf5d2d5 template path for handlers: include 2012-05-21 21:40:07 -07:00
Michael DeHaan
1125ca548a Merge pull request #411 from mgwilliams/bug-fetch-module
Fetch module: run dwim on dest after templating, not before
2012-05-20 07:01:11 -07:00
Matthew Williams
effd931031 dim fetch dest after templating 2012-05-19 18:59:23 -07:00
Michael DeHaan
8e88667f82 Fix hosts being in multiple groups, and duplicate host references in the same inventory file. 2012-05-19 17:24:54 -04:00
Michael DeHaan
7302b7bbc4 Merge pull request #402 from denen99/devel
updated connection.py to have the same interface for exec_command on both LocalConnection and ParamikoConnection classes
2012-05-17 04:06:02 -07:00
Adam Denenberg
3dfd240b86 updated connection.py to have the same interface for exec_command on both LocalConnection and ParamikoConnection classes 2012-05-17 00:11:50 -04:00
Jeroen Hoekx
3eff44a2b0 Arguments to setup module should be json. 2012-05-15 17:43:01 +02:00
Seth Vidal
d80fd74b64 make sure private_key_file is hooked up in playbooks, too 2012-05-14 16:52:48 -04:00
Seth Vidal
96ef6482c5 add --private-key option and related infrastructure to make paramiko work
with a private key file - not just an agent or pw
2012-05-14 16:14:38 -04:00
Daniel Néri
e4991d1a61 In the template module, use utils.template_from_file instead of reimplementing it inline 2012-05-13 20:57:01 +02:00
Daniel Néri
f8b17ef8d3 For utils.template_from_file, change 'no_engine' default to True
This now follows the other template functions, and implicitly also
fixes that playbook handler includes were still processed by Jinja2.
2012-05-13 20:42:11 +02:00
Daniel Néri
4b0480dd9d Set 'hostvars' before performing variable replacements 2012-05-13 20:36:08 +02:00
Michael DeHaan
60d44e1a01 Squashed commit of the following, plus some streamlining (MPD).
commit e00368e7c65c65bed11fcaaf83fe8b093dbf492e
Merge: 2ea7110 c039aa0
Author: Michael DeHaan <michael.dehaan@gmail.com>
Date:   Thu May 10 01:43:10 2012 -0400

    Merge branch 'devel' of https://github.com/weaselkeeper/ansible into weaselkeeper-devel

commit c039aa0915
Author: Jim Richardson <weaselkeeper@gmail.com>
Date:   Fri May 11 17:55:13 2012 -0700

    cleanup and simplification of ANSIBLE_REMOTE_TMP feature

commit d87f15b796
Merge: 5917aba 4c2fd25
Author: Jim Richardson <weaselkeeper@gmail.com>
Date:   Fri May 11 17:30:16 2012 -0700

    Merge branch 'devel' of github.com:weaselkeeper/ansible into devel

commit 5917aba761
Author: Jim Richardson <jrichardson@classmates.com>
Date:   Wed May 9 11:25:45 2012 -0700

     ANSIBLE_REMOTE_TMP environment variable sets where ansible will stuf tmp files on remote host.  Default is /var/tmp for root, and $HOME/.ansible/tmp for non-root

commit 4c2fd25777
Author: Jim Richardson <jrichardson@classmates.com>
Date:   Wed May 9 11:25:45 2012 -0700

     ANSIBLE_REMOTE_TMP environment variable sets where ansible will stuf tmp files on remote host.  Default is /var/tmp for root, and $HOME/.ansible/tmp for non-root
2012-05-10 01:50:22 -04:00
Michael DeHaan
ccab8ac2c0 Reinstate raw module 2012-05-10 01:14:30 -04:00
Michael DeHaan
b7bb0ab225 Do not read user's SSH config file because only reading it partially is confusing to everyone :) 2012-05-09 23:45:37 -04:00
Michael DeHaan
e060b06081 Allow hosts not in inventory to override inventory with -i "host1,host2:port" etc, which is the original intent
of --override-hosts.
2012-05-09 23:26:45 -04:00
Michael DeHaan
f8807da57b Merge pull request #363 from jhoekx/template-only-if
Fix correct variable expansion in includes only_if.
2012-05-11 15:55:09 -07:00
Jeroen Hoekx
cd9f926b5f Fix correct variable expansion in includes only_if.
There's not need to run the complete include through the templating engine.
Several variables were not included before the conditional was evaluated.
2012-05-11 15:55:33 +02:00
Michael DeHaan
dab50574e0 Merge pull request #356 from jkleint/singleton-notify
Support single handlers for notify.
2012-05-10 17:04:54 -07:00
John Kleint
d9427db14b Support single handlers for notify. 2012-05-10 15:37:30 -04:00
John Kleint
4cf0c5550e Fix YAML hosts list. 2012-05-10 15:13:32 -04:00
Jeroen Hoekx
3cbc229990 Support list indexing in varReplace. 2012-05-10 19:25:28 +02:00
Michael DeHaan
4819ce4989 Merge pull request #349 from jhoekx/template-unicode-fixes
Fixup unicode varReplace templating.
2012-05-10 05:05:50 -07:00
cocoy
c1fd1348b1 Fix for bug #264 2012-05-10 18:53:24 +08:00
Jeroen Hoekx
74e21e6154 Fixup unicode varReplace templating.
The original patches should have conflicted?
53bde0bf51 vs efde61e537
2012-05-10 10:11:14 +02:00
Stephen Fromm
fa9bfbba13 Fix for sudo to another non-root user (issue #353)
mktemp creates the temp directory 700 only.  If the sudo-user is not
root, the other user will not be able to run the command (Permission
denied error).  This adds the executable bit for all on the temp
directory.
2012-05-11 11:48:31 -07:00
Michael DeHaan
36639186e0 Merge pull request #362 from jhoekx/uppercase-vars
Allow camelCase variables in varReplace.
2012-05-11 10:06:21 -07:00
John Kleint
fba2bdcf0c Don't read from Paramiko's stderr since there isn't one. 2012-05-11 10:53:35 -04:00
Jeroen Hoekx
dc60f2d844 Allow camelCase variables in varreplace. 2012-05-11 14:14:53 +02:00
Michael DeHaan
262b35e7d3 override-hosts is gone since we can't load inventory for hosts (so it's not an whitelist), but we can
still support hosts outside of inventory if you pass in an array of hosts.  Ports are supported,
but not much other info.
2012-05-09 21:53:09 -04:00
Michael DeHaan
cb6f0f4284 Merge pull request #346 from jhoekx/improve-varreplace
Support nested variables in varReplace
2012-05-09 17:25:07 -07:00
Jeroen Hoekx
2bbc05185e Make no_engine the default templating action. 2012-05-09 16:15:43 +02:00
Jeroen Hoekx
82144fd543 Support nested variables in varReplace. 2012-05-09 16:15:43 +02:00
Jeroen Hoekx
98f93fcc07 Preserve trailing newline after templating.
Jinja seems to eat trailing whitespace. A lot of tools complain about this: iptables-restore, iscsid...
2012-05-09 10:31:32 +02:00
Matthew Williams
e56023b8bb Template dest and src parameters 2012-05-08 07:12:30 -07:00
Michael DeHaan
d149c1823a Merge pull request #339 from mgwilliams/feature-unicode
Allow unicode (utf8) in templates
2012-05-09 17:16:59 -07:00
Matthew Williams
43b1727f6a removed debug code 2012-05-08 16:05:43 -07:00
Matthew Williams
39a92f9cd6 allow unicode (utf8) characters in jinja templates 2012-05-08 16:03:51 -07:00
Michael DeHaan
0894206467 Be able to use --extra-vars to set the hosts variable 2012-05-07 23:37:09 -04:00
Michael DeHaan
07508ad535 Since host variables are becoming important, it did not make sense to sustain --override-hosts, with the ability
to create hosts that didn't have inventory information, but also existed, in various groups.
2012-05-07 23:16:20 -04:00
Michael DeHaan
fc300723da Revert "fix indentation"
This reverts commit 42b55a07cd.
2012-05-07 21:46:45 -04:00
Michael DeHaan
e1914a0e62 Revert "fix the get_hosts() error in get_groups returning a dict not a list of group objects"
This reverts commit f41fb90d78.
2012-05-07 21:46:36 -04:00
Michael DeHaan
121d7c4ece Merge pull request #329 from skvidal/devel
inventory and indentation
2012-05-08 03:54:41 -07:00
Jeroen Hoekx
e09572a8e1 Inventory: undefined group -> ungrouped.
Also change test name collision.
2012-05-08 09:44:59 +02:00
Jeroen Hoekx
d419a13ca7 Inventory: support list of vars in host. 2012-05-08 09:44:29 +02:00
John Kleint
710d085def Fix non-sudo execution, add --sudo-user to ansible-playbook. 2012-05-07 19:58:16 -04:00
Seth Vidal
cd28d82639 fix indentation 2012-05-07 18:10:52 -04:00
Seth Vidal
279e5e4522 fix the get_hosts() error in get_groups returning a dict not a list of group objects 2012-05-07 18:09:57 -04:00
Michael DeHaan
05545e3735 Fixup the previous sudo_user support patch to work with playbooks. 2012-05-06 18:24:45 -04:00
Jim Richardson
5582e6a4f1 sudo -u works now. Needs testing and maybe a bit of cleanup 2012-05-06 18:24:45 -04:00
Jim Richardson
2cd8d7b5e4 first bit of getting sudo -u functionality 2012-05-06 18:24:45 -04:00
Jim Richardson
8d39ae709c sudo -u works now. Needs testing and maybe a bit of cleanup 2012-05-06 18:24:44 -04:00
Jim Richardson
93a20a33e9 first bit of getting sudo -u functionality 2012-05-06 18:24:44 -04:00
Michael DeHaan
f718fc99b7 Add missing file 2012-05-06 18:02:53 -04:00
Michael DeHaan
157d21b1c3 Add tests for new advanced inventory features (groups of groups, group variables) in the default INI format file. 2012-05-06 18:01:11 -04:00
Michael DeHaan
1a00e2635e Further work on making the YAML inventory parser use the new inventory objects. 2012-05-06 17:03:17 -04:00
Michael DeHaan
a8f0b5fd06 Fix playbooks such that they work with external inventory scripts. We really want to find out why the 'all'
group isn't available, but group vars don't make sense for external inventory anyway.
2012-05-06 15:00:17 -04:00
Michael DeHaan
256377166a Reinstate external inventory script support this time using the new more OO-ey inventory system.
Next up: YAML format.
2012-05-06 14:47:05 -04:00
Michael DeHaan
5730a29814 missing files 2012-05-05 16:37:28 -04:00
Michael DeHaan
0669ce858a Refactored inventory to make it object oriented, need to make YAML format and executable script
format compatible with this still, and add some tests for INI-style groups of groups
and variables.
2012-05-05 16:31:03 -04:00
Michael DeHaan
b300aac551 Include files are no longer to be considered Jinja2 templates, but individual THINGS
in included files can still be templated just like top level playbooks.  Resolves
some issues about statements being evaluated before facts were available
2012-05-02 00:28:19 -04:00
Michael DeHaan
02efcdced6 Merge branch 'devel' of https://github.com/skvidal/ansible into skvidal-devel 2012-05-01 22:58:47 -04:00
Seth Vidal
38ea61054f if a playbook has no vars - still include the global vars 2012-05-03 15:52:02 -04:00
Seth Vidal
dc35dd99c0 inventory group 'all' variables are global variables
applied to every host and available all over
they are read in so that ones defined first can be used to define
the later ones.
2012-05-02 18:30:58 -04:00
Jeroen Hoekx
03541baba7 Define 'inventory_hostname' variable for hosts. 2012-05-02 09:56:58 +02:00
John Kleint
cbbaee8a9f Remove command timeout. 2012-05-02 16:25:04 -04:00
Jeroen Hoekx
f14c1e3e91 Async: print one poll message per polling cycle.
Instead of one per host per polling cycle.
2012-05-01 18:38:26 -04:00
Jeroen Hoekx
029fe1273c Modify /usr/bin/ansible and playbooks to use the new async API. 2012-05-01 18:38:26 -04:00
Jeroen Hoekx
ce9a8c9ffc Introduce Async API in Runner. 2012-05-01 18:38:26 -04:00
Jeroen Hoekx
b87710a1df Introduce group_names in template variables.
This is a list of all the groups a host is in.
2012-04-28 18:23:44 +02: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
f939f3fdaf Playbook can now take a 'name' which it will show when starting the play 2012-04-27 00:08:06 -04:00
Michael DeHaan
67d1169674 fix code handling if module_vars is None 2012-04-26 23:18:29 -04:00
Michael DeHaan
aa8ae85070 Add playbook example for first_available_file 2012-04-26 23:03:14 -04:00
Michael DeHaan
3804910187 Some tweaks to first_available_file mostly in terms of error handling and not trying src= to be present
as it is not used here.
2012-04-26 23:00:33 -04:00
Seth Vidal
72fd971822 fall through file source list: first_available_file support
add first_available_file look up to _execute_template and _execute_copy
to runner.

add this data to playbook handler so it can be included into module_vars
2012-04-27 16:43:55 -04:00
Michael DeHaan
40f5469869 minor personal style preference on 'not' 2012-04-26 20:42:20 -04:00
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
Michael DeHaan
de70277173 No need to save setup files to disk, this is what SETUP_CACHE effectively does. 2012-04-17 19:39:11 -04:00
Jeroen Hoekx
aa555b8b16 Inventory: AnsibleError is not global... 2012-04-17 15:29:59 +02:00
Michael DeHaan
da6cb1ca6e Less scrolling over constructor params now that documentation follows 2012-04-16 23:51:03 -04:00
Michael DeHaan
3f26a1c7f6 verbose option is not being used, so remove it. debug variable still exists. 2012-04-16 23:47:41 -04:00
Michael DeHaan
78b5cd64d0 Add pydoc for constructors. Some arguments can be trimmed as we plan to remove the need for them (like setup_cache and
maybe module_vars) with various pending refactoring.
2012-04-16 23:45:15 -04:00
Michael DeHaan
9ce27be878 Remove extra_vars tests 2012-04-16 23:03:04 -04:00
Michael DeHaan
35fdf6636b Allow --user for playbooks, no need for port setting as can specify in inventory file now. 2012-04-16 22:15:55 -04:00
Michael DeHaan
08468dcb0c Fixes to make ports DWIM. 2012-04-16 21:52:15 -04:00
Michael DeHaan
957867e088 Merge branch 'yaml-inventory' of https://github.com/jhoekx/ansible into jhoekx-yaml-inventory
Conflicts:
	lib/ansible/runner.py
2012-04-16 21:14:44 -04:00
Michael DeHaan
a5cb16c9d7 Use correct user to determine host files path, do not reuse .ansible
which is already taken for ansible management ops.
2012-04-16 21:12:54 -04:00
Michael DeHaan
6307267cf3 As part of the support for access to external nodes information, save fact data into /var/lib/ansible/setup_data
OR a per-user directory when running from playbooks.  Technically this info is also available via the SETUP_CACHE
but that is a bit more complex of a construct and it would be better to not cross the streams.
2012-04-16 21:12:54 -04:00
Jeroen Hoekx
8c3206c99f Return a copy of the host variables. 2012-04-16 10:59:34 +02:00
Jeroen Hoekx
961ccdb2f4 List hosts in no group in the ungrouped group. 2012-04-16 10:55:08 +02:00
Jeroen Hoekx
3a24aa9a70 Add YAML inventory format.
See test/yaml_hosts for an example.

Hosts can be part of multiple groups.

Groups can also have variables, inherited by the hosts.
There is no variable scope, last variable seen wins.
2012-04-16 10:38:35 +02:00
Jeroen Hoekx
54f4526160 Export SSH port number as host variable. 2012-04-16 09:16:29 +02:00
Jeroen Hoekx
f04041b37d Ignore port numbers in simple inventory format 2012-04-16 09:16:29 +02:00
Jeroen Hoekx
746f1b92ae Reimplement the class method on Runner. 2012-04-16 09:16:29 +02:00
Jeroen Hoekx
c5cae87eca Refactor inventory code out of Runner.
This introduces the Inventory class.

Playbook uses the internals of Runner to limit the number of hosts to poll
asynchronously. To accomodate this, Inventory can be restricted to specific
hosts.
2012-04-16 09:16:28 +02:00
Michael DeHaan
d8f9d7c6c9 Use correct user to determine host files path, do not reuse .ansible
which is already taken for ansible management ops.
2012-04-14 16:08:04 -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
3454fa9950 As part of the support for access to external nodes information, save fact data into /var/lib/ansible/setup_data
OR a per-user directory when running from playbooks.  Technically this info is also available via the SETUP_CACHE
but that is a bit more complex of a construct and it would be better to not cross the streams.
2012-04-14 11:58:08 -04:00
Michael DeHaan
31d4ee32d1 Looping! With items! See examples/playbook/loop_with_items.yml for details 2012-04-14 09:55:24 -04:00
Michael DeHaan
347637339c Merge remote branch 'public/integration' into integration 2012-04-13 19:33:57 -04:00
Michael DeHaan
c3cad50075 Update manpages, fix missing variable assignment 2012-04-13 19:33:19 -04: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
Jeroen Hoekx
a975852f66 Module_arguments can be unicode. 2012-04-13 15:32:33 +02:00
Michael DeHaan
6b50078881 Add defaults to command help to avoid a certain class of user questions. 2012-04-12 21:30:49 -04:00
Michael DeHaan
6129574290 Include default value for connection in help. 2012-04-12 21:20:37 -04:00
Michael DeHaan
09a0b9bea8 If the module return is not parsed, always show stderr information even if -D (debug)
is not specified.  This will help for users that don't have prerequisites installed
(like python-simplejson on old RHEL) and do not know to run -D.
2012-04-12 21:18:09 -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
08c593bee1 Warn if no hosts matched 2012-04-11 21:05:46 -04:00
Michael DeHaan
f3489a53cd English error messages if src and dest are left off the copy, template, or fetch modules 2012-04-11 20:57:41 -04:00
Michael DeHaan
a0480a1bc5 Block some paramiko warnings that are not relevant. 2012-04-11 20:20:55 -04:00
Michael DeHaan
95e045d153 Remove remote logging as we're going to move this logging to the modules for performance reasons. 2012-04-11 20:15:17 -04:00
Michael DeHaan
245aa9bf8e Some tweaks to the fetch module. 'err' return was for stderr, so that should be empty string.
Some minor code shortening.  Added a test to TestRunner.
2012-04-11 20:12:01 -04:00
Michael DeHaan
62224271e9 Merge pull request #131 from mgwilliams/feature-fetch-module
Fetch Module
2012-04-11 16:55:51 -07:00
Stephen Fromm
40fc9a3249 Update playbook to be transport aware
This adds transport variable to playbook.py.  It can be set with
'connection' in the playbook file.
2012-04-11 09:39:04 -07:00
Matthew Williams
31d3f52b28 fetch to host specific directory 2012-04-11 09:14:36 -07:00
Matthew Williams
611e3fec4c fetch 'module' -- working with paramiko and local connections 2012-04-10 20:23:25 -07:00
Michael DeHaan
4c75b7f3ad Merge commit '8ae71cc' into integration
Conflicts:
	bin/ansible
	bin/ansible-playbook
	lib/ansible/utils.py
2012-04-10 21:13:01 -04:00
Michael DeHaan
1d75a29ec9 Allow variables coming in from the playbook and the API to be expressed as dictionaries throughout their full life cycle
such that nested data can be made available in templates and playbooks.
2012-04-10 20:58:40 -04:00
Stephen Fromm
b5061bb62e Verify that effective uid == remote_user when transport is local
Raise exception if effective uid of process is not the same as
remote_user.
2012-04-10 16:27:19 -07:00
Stephen Fromm
5d74fedeb9 Update Runner to default to C.DEFAULT_TRANSPORT
This also uses self.transport when instantiating Connection object.
2012-04-10 16:17:39 -07:00
Stephen Fromm
1391481523 Add support for -c, --connection argument to specify connection type
Adds support to specify connection type to use.  The option -c,
--connection is added when connect_opts is set to True.  connect_opts is
added to make_parser() and base_parser_options().
2012-04-10 16:13:18 -07:00
Stephen Fromm
896f8de446 Add DEFAULT_TRANSPORT and DEFAULT_TRANSPORT_OPTS constants
DEFAULT_TRANSPORT is set to paramiko.  DEFAULT_TRANSPORT_OPTS is a list
of possible transport options; it is set to local and paramiko.
2012-04-10 16:09:20 -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
Seth Vidal
8ae71cc7b1 go back to using a normal optparser to add options instead of the dict
interface.

add very small subclass of OptionParser to sort the options so mdehaan is happy
2012-04-10 13:51:58 -04:00
Brad Olson
f840c0d167 Wired in Michael's usage string optparse style. 2012-04-09 23:12:05 +00:00
Michael DeHaan
6749903e57 Allow explicit request of the local connection. 2012-04-07 14:51:00 -04:00
Michael DeHaan
da9d4eb29a Merge pull request #123 from sfromm/localconnection
Add LocalConnection class to connection.py
2012-04-07 11:41:13 -07: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
7b9856bc0e Modification on top of skvidal's common options patch to keep options to command line tools sorted. 2012-04-06 10:59:15 -04:00
Seth Vidal
7e50d170a8 move the bulk of the opt parsing out of ansible/ansible-playbook and into utils
for other scripts to use.
2012-04-05 17:06:23 -04:00
Jeroen Hoekx
ab86726a15 Introduce per task variables and push them to templates. 2012-04-04 13:39:03 +02:00
Jeroen Hoekx
edd5baad8b Refactor _transfer_argsfile to generic string transfer function. 2012-04-04 13:36:21 +02:00
Michael DeHaan
09e690fd7c Indentation error causing forks to not be parallel. Ahem :) 2012-04-03 20:20:55 -04:00
Michael DeHaan
778fe8755f Merge pull request #110 from jhoekx/remote-vars
Always add vars to a play.
2012-04-03 17:07:00 -07:00
Michael DeHaan
eae1fdd734 Merge pull request #109 from jeckersb/version-0.0.2
Bump release to 0.0.2
2012-04-03 17:06:09 -07:00
Jeroen Hoekx
e38ae18627 Always add vars to a play.
A play without vars section would fail to use variables given in an include. They would be added to the dict returned by play.get, but the dict would not be added to the play.
2012-04-03 17:35:05 +02:00
John Eckersberg
82b781925c pep8 fix 2012-04-03 09:58:00 -04:00
John Eckersberg
5aad4bacc7 Bump release to 0.0.2 2012-04-03 09:51:05 -04:00
Michael DeHaan
e5d5b072db Merge remote branch 'public/integration' 2012-04-02 20:02:46 -04:00
Michael DeHaan
59a1ff31db Merge pull request #103 from jeckersb/no-shebang-on-callbacks.py
Remove shebang from callbacks.py
2012-04-02 16:58:41 -07:00
Michael DeHaan
2f1f0d44b4 Merge pull request #106 from mgwilliams/honor-hostfile-returncode
raise error if executable host file execution fails
2012-04-02 16:58:20 -07:00
Matthew Williams
461a4e78c2 raise error if executable host file execution fails 2012-04-02 15:00:28 -07:00
Matthew Williams
c742b8eb0b bugfix for extra-vars 2012-04-02 14:57:37 -07:00
Seth Vidal
bcef25f7eb add vars_prompt to playbooks
- this allows some vars to be prompted for at the start of the playbook
  setup
- defaults to no output since this would mostly be used for passwords
2012-04-02 17:46:02 -04:00
John Eckersberg
2dad8cc27c Remove shebang from callbacks.py
It is not +x, and has no __main__.  It draws ire of rpmlint.
2012-04-02 17:19:05 -04:00
Seth Vidal
04aecdcf34 before we run the actual module/command - emit what that would be to the logs 2012-04-02 13:29:12 -04:00
Michael DeHaan
2511992659 Surface module debug (-D) to /usr/bin/ansible also 2012-03-31 11:45:29 -04:00
Michael DeHaan
4a8dc50249 Merge pull request #97 from jhoekx/stderr-logging
Stderr logging
2012-03-31 08:01:48 -07:00
Jeroen Hoekx
74ae4b29ad Add a debug attribute to Runner/Playbook.
This prints the stderr of the executed modules on local stderr.
Most methods on Runner now return a fourth "err" parameter.
2012-03-31 09:32:13 +02:00
Jeroen Hoekx
fb1a313974 Correct default user and port in playbook.
They are set in the constructor.
2012-03-31 09:11:07 +02:00
Michael DeHaan
6275e57718 pyflakes: Unused import / unused var 2012-03-30 23:04:02 -04:00
Michael DeHaan
9569be8bdb Need for quoting/unquoting problems go away once module_args are all treated as strings throughout. 2012-03-30 22:52:38 -04:00
Michael DeHaan
3ded27fe35 Treat module args as strings everywhere to avoid unneccessary shlex and requoting 2012-03-30 22:47:58 -04:00
Michael DeHaan
f11de2f5c9 --extra-vars option for ansible-playbook
Conflicts:

	lib/ansible/playbook.py

Removed unneccessary shlex and replaced with basic split, some repurcussions in runner
that can be eliminated once we consistently pass args as a string (soon).
2012-03-30 22:29:06 -04:00
Michael DeHaan
6db87a5018 Minor style fix, update test to match quote fix patch 2012-03-30 21:57:34 -04:00
Matthew Williams
ec6f488d1f shell quoting fixes
(edited author's original commit comment -- MPD)
2012-03-30 21:57:33 -04:00
Matthew Williams
99d5796605 support for quotes strings in command module (via posix=False), related fixes to keep other things from breaking 2012-03-30 21:57:33 -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
7ae75eb14b Default sudo is false 2012-03-28 22:55:59 -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
4971101f27 Handler doesn't take this param. 2012-03-28 20:33:44 -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
Michael DeHaan
b30ddc4520 Expose remote_port option in playbook 2012-03-28 19:31:17 -04:00
Christopher Johnston
68818ad1fe add support for remote ports in playbooks 2012-03-28 15:02:50 -07: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
Michael DeHaan
b1471bf857 Add more comments to the callbacks file 2012-03-26 22:05:11 -04:00
Michael DeHaan
95670ce6b5 remove unused function 2012-03-26 21:58:28 -04:00
Michael DeHaan
f9da7cb180 remove functions that are no longer used 2012-03-26 21:56:18 -04:00
Michael DeHaan
35d77d0433 Make it an error to try to hit a change handler that doesn't exist 2012-03-26 21:31:48 -04:00
Michael DeHaan
f693759252 Style fixes from pep8 makefile target 2012-03-26 21:25:43 -04:00
Michael DeHaan
f074f1c4c4 Fixes from pyflakes 2012-03-26 21:23:28 -04:00
Michael DeHaan
35c8750bbb Fix tree view to work with callbacks 2012-03-26 21:18:48 -04:00
Michael DeHaan
45a455a805 Make /usr/bin/ansible output realtime and also delete some code! 2012-03-26 21:17:11 -04:00
Michael DeHaan
eb67a91c57 Merge remote branch 'public/master' 2012-03-26 19:36:03 -04:00
Michael DeHaan
aaafd12b59 rm FIXMEs 2012-03-26 19:35:53 -04:00
Jeroen Hoekx
a370261dce Playbook: create one task per include instead of per argument. 2012-03-26 10:30:48 +02:00
Michael DeHaan
6dda6f12dc Applying callback model to runner, and using that in playbooks, so output can be more immediate in playbooks.
(Runner still does not use callbacks for default output)
2012-03-25 19:05:27 -04:00
Michael DeHaan
ab55fa4266 Revert "Only override the pattern if it is ommitted"
This reverts commit bb0bf9eef4.
2012-03-24 16:21:44 -04:00
Michael DeHaan
bb0bf9eef4 Only override the pattern if it is ommitted 2012-03-24 16:20:47 -04:00
Michael DeHaan
9df612f007 Add a "-o" override option so hosts not in a playbook can still be managed by a playbook. 2012-03-24 16:19:38 -04:00
Michael DeHaan
292ac4aad2 Make it such that the 'name' element of each playbook line is optional. 2012-03-23 21:06:54 -04:00
Michael DeHaan
44d4dede92 Split conditional imports in playbook into subfunction, fix small bug in event reporting on playbook
actions.
2012-03-23 21:03:25 -04:00
Michael DeHaan
b43019f3a1 In playbooks, a return code (rc) of non-zero should fail the playbook. 2012-03-23 20:53:57 -04:00
Michael DeHaan
6ab615c724 Code cleanup for playbooks, also added 'on_skipped' callback 2012-03-23 20:51:26 -04:00
Seth Vidal
53446d6d45 make sure the setup step in a playbook has the sshpass included 2012-03-23 16:41:44 -04:00
Seth Vidal
89d4bc542c fix up minor type - AnsibleException should be AnsibleError 2012-03-23 11:59:08 -04:00
Michael DeHaan
a8c921cbcc Allow groups to be passed to runner API to make parse_hosts optional, misc fixes as a result of refactoring in Runner.
Cleanup in Playbooks module is next.
2012-03-22 00:30:05 -04:00
Michael DeHaan
94605b811b Fixes from refactoring 2012-03-21 23:47:58 -04:00
Michael DeHaan
6a7aac38c5 misc cleanup in the runner module, splitting some things out into utils, breaking up functions into smaller functions. 2012-03-21 23:39:09 -04:00
Michael DeHaan
7ed734dfb2 move callbacks to seperate file, anticipating callbacks for Runner() as well 2012-03-21 22:18:57 -04:00
Michael DeHaan
7883f414ce unused module 2012-03-21 21:03:32 -04:00
Michael DeHaan
e6406fa5a7 Allow variable expressions to be stored as variables themselves, do some things to allow setup strings
to more easily contain spaces without being mangled, which is neccessary because of the above.
2012-03-21 20:00:48 -04:00
Michael DeHaan
a5f4ca50b8 Ratchet up logging a few notches prior to controlling w/ verbosity settings 2012-03-20 22:29:21 -04:00
Michael DeHaan
b5c62ec068 Enhance logging, way to gate verbosity levels pending. 2012-03-20 21:44:01 -04:00
Michael DeHaan
dfbe591cc0 Add "only_if" capability, which allows task steps to be skipped if they do not match a conditional. 2012-03-20 19:55:04 -04:00
Michael DeHaan
149cc57b0f remove unneeded code 2012-03-19 23:54:47 -04:00
Michael DeHaan
c05e7fd83e Fix typing issue 2012-03-19 22:46:54 -04:00
Michael DeHaan
4de7bbb169 Allow conditional imports, see examples/playbook3.yml comments for a full explanation. Extensive
refactoring of playbooks now warranted, which we'll do before we move on.   This variable assignment
system makes nearly all possible magic possible, for we can use these variables however we like,
even as module names!
2012-03-19 22:42:31 -04:00
Michael DeHaan
5ed2b894d9 Add an additional way to dereference a variable in a playbook, $foo
(Using varReplace function originally from yum, thanks Seth)
2012-03-19 19:32:38 -04:00
Michael DeHaan
af9596307d Move templating into a utils function. Reuse is our friend. 2012-03-19 19:23:14 -04:00
Michael DeHaan
c1fe0dd719 Quote long variables in playbooks when feeding them to the setup command 2012-03-18 19:50:22 -04:00
Michael DeHaan
5371a9e497 Regression tests for playbooks, logging the events they call via callbacks. 2012-03-18 19:25:56 -04:00
Michael DeHaan
45abe3c16b Add unit tests for playbooks, and fix an error caught by one 2012-03-18 18:29:11 -04:00
Michael DeHaan
9c5ec886a6 Import cleanup, plus have /bin/ansible remind you if no hosts were matched by a pattern (for instance, assume
there was a typo in the pattern)
2012-03-18 17:53:58 -04:00
Michael DeHaan
9e07b24239 Fix indentation 2012-03-18 17:25:22 -04:00
Michael DeHaan
6777268f4c Fixup the code that allows facter/ohai/other data to bubble up and be used in future action lines. It's a niche
case compared to usage in templates but it should work and will be wanted later for conditional support.
2012-03-18 17:24:09 -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
33aa50eae7 Inside of runner, do not 'import *' from utils, so we can more easily tell where functions come from 2012-03-18 17:04:07 -04:00
Michael DeHaan
9837a616eb Preserve changed data on file and template ops when the mode operations don't result in a change but the files
were still replaced.
2012-03-18 16:58:00 -04:00
Michael DeHaan
5905974737 Fix variable referenced before assignment when not using external variables script 2012-03-31 11:03:29 -04:00
Michael DeHaan
3495d402c7 Default for class variable 2012-03-31 11:02:10 -04:00
Michael DeHaan
9f6d98844e If the inventory file is EXECUTABLE, treat it as a file returning JSON, if called directly, return the host
and groups list.  If called with an argument of a host name, return the key=value data for that particular
host.
2012-03-30 19:06:14 -04:00
Michael DeHaan
f39944b89b Update example to use correct service state; minor pep8 indent/spacing fixes 2012-03-15 23:10:03 -04:00
Michael DeHaan
24923c2e17 Purge unused imports per pyflakes 2012-03-15 23:06:59 -04:00
Michael DeHaan
63818000b4 auto call the file module after copy/template module usage in runner
note some changed=True/False detection bits in file module still need tweaking
2012-03-15 22:32:14 -04:00
Michael DeHaan
be55145a1e Initial crack at the file module 2012-03-15 21:53:14 -04:00
Michael DeHaan
1a0672fd1e Fix exception type 2012-03-14 12:51:26 -04:00
Michael DeHaan
c909b66864 use iteritems vs items(), probably doesn't matter that much 2012-03-14 21:56:49 -04:00
Michael DeHaan
4bde4926c3 Modules don't have to return JSON, key=value pairs is ok. 2012-03-14 21:16:15 -04:00
Michael DeHaan
40fd778e2c 'shell' is a magic module that executes the command module with shell=True 2012-03-14 20:40:06 -04:00
Michael DeHaan
e8751baaf3 Remove remote log function as it's only used in one place now 2012-03-14 20:00:09 -04:00
Michael DeHaan
696b67f935 Fix async to use the new argfiles method (wrapping brain around rock, really must write module development guide) 2012-03-14 19:57:56 -04:00
Michael DeHaan
3ea9174ed7 Split argsfile handling into subfunction, attempt to apply argsfile logic to setup 2012-03-14 19:05:19 -04:00
Seth Vidal
a9948f97c6 convert runner to use an args file rather than just arguments passed
on the command line
2012-03-14 18:46:33 -04:00
Michael DeHaan
e3b4981feb Various additions to make sure timed out and failed hosts are taken out of the playbook even if failed
during setup, async tasks, or poll operations.  This introduced some redundancy so I've made some
notes in the code where things need to be refactored to remove them.
2012-03-13 21:30:34 -04:00
Michael DeHaan
4ae98ed92d Upgrades to error handling, now general try/catch available. 2012-03-13 20:59:05 -04:00
Michael DeHaan
09a7119e74 Annotate more files, fix missing imports messing with playbooks. Hey Tim, please test your stuff :) 2012-03-13 19:19:54 -04:00
Tim Bielawa
dfd2c6dce3 Implement friendlier error handling.
Generic AnsibleError exception + host inventory missing exception.
First shot at catching these in a generic way in bin/ansible*.
2012-03-12 23:11:54 -04:00
Michael DeHaan
ce85222fa6 What we are running is actually a "play" (multiple plays per playbook) so rename the function to make it more clear 2012-03-12 22:05:51 -04:00
Michael DeHaan
adf1492da2 Add external vars example 2012-03-12 22:03:20 -04:00
Michael DeHaan
e582bd5ec5 Add fire and forget example 2012-03-12 21:02:38 -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
db7ba87111 Add polling logic in runner such that all actions get kicked off everywhere then polling
happens only on needed hosts, allowing some hosts to fail and drop out of the running.
2012-03-11 20:54:54 -04:00
Michael DeHaan
49a636d8a0 Fixed up async and polling logic. 2012-03-11 19:27:43 -04:00
Michael DeHaan
5be1a612d3 Add async polling logic to runner. Will add to playbook shortly, have to diagnose why paramiko
is not letting async_wrapper daemonize itself when it does work fine when directly executed.
2012-03-11 18:40:35 -04:00
Michael DeHaan
60a13cf540 Ignore commented out lines in the ansible setup files. 2012-03-10 21:19:41 -05:00
Michael DeHaan
4c9dd972b4 Fixes for output formatting 2012-03-10 13:40:08 -05: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
Seth Vidal
b576e389b1 runner buglet and yum module
runner: fix buglet causing logger output to include a u for the command
yum: add yum module:
   ensure=installed pkg=name/name.arch/name-ver-rel.arch
   ensure=removed pkg=name/name.arch/name-ver-rel.arch
   list=installed
   list=updates
   list=available
   list=pkgspec
   list=repos
2012-03-09 18:33:58 -05:00
Seth Vidal
19b784e480 if we've failed a connection to a host - we cannot set items to the
'conn' object since it is not an object on failure - it's a string.
2012-03-09 00:19:55 -05:00
Tim Bielawa
95502c3089 Adding version and author to ansible init. 2012-03-07 12:02:05 -05:00
Michael DeHaan
8e20ed3714 src= parameters for template and copy operations can be relative to the playbook (for /usr/bin/ansible-playbook) or current directory (for /usr/bin/ansible) 2012-03-06 21:13:50 -05:00
Michael DeHaan
7eedc3fb1a Breakout includes into seperate functions, allow vars to apply to handlers but handlers
still may not be parameterized because it does not make sense to import them more than
once since they are keyed by name.
2012-03-06 21:01:05 -05:00
Michael DeHaan
85e0de5bb2 Move print statements out of playbook.py and back into CLI so we can simplify playbook operations
independent of output, and can also see all the output nicely grouped together if we want
to reformat it or make summaries of statistics.
2012-03-06 19:24:36 -05:00
Michael DeHaan
0935506d6f Templating as non-root should not require passing in the metadata= parameter. 2012-03-05 22:23:56 -05:00
Michael DeHaan
4ee4ddcd7c Parameterized include statements can see top level variables and also be passed specific variables!
Code needs cleanup, but works
2012-03-05 22:00:22 -05:00
Michael DeHaan
8d57ceecf1 Factoids and push variables via setup are now available to be templated in command args
as well as template files.  PLUS, variables are now expressed in playbooks without having
to know about the setup task, which means playbooks are simpler to read now.
2012-03-05 20:09:03 -05:00
Tim Bielawa
f2c2786a14 Update constants.py to pull module path and the hosts file from the
environment (ANSIBLE_{LIBRARY,HOSTS}) if defined.

Update manpages to represent this.

Also update the env-setup script to set ANSIBLE_{LIBRARY,HOSTS}.
2012-03-05 16:08:36 -05:00
Tim Bielawa
b190ea4b62 Fix parse_hosts to not blow up on ungrouped hosts. 2012-03-05 14:09:01 -05:00
Michael DeHaan
fae3a71899 WIP on async tests 2012-04-04 11:24:22 -04:00
Michael DeHaan
369b9cde1c Add test for template module and make 'dark' errors clearer if we get output back and the JSON
is not parseable
2012-04-04 10:57:54 -04:00
Michael DeHaan
8d06c074b1 * Added uptime.py as an example of somewhat minimal API usage & reporting
* Pattern in API now has a default
* Fixed bug in template module operation detected from running playbook (tests for that pending)
* Workaround for multiprocessing lib being harmlessly squeaky (feeder thread got sentinel)
2012-04-04 10:27:24 -04:00
Michael DeHaan
db57933614 Allow ":" to be used to split patterns as well as ";" so if you are just using group names or fully explicit names you do not need to use shell quoting at all. Obviously if you use wildcards like "*" you wouldstill. 2012-03-03 14:26:59 -05:00
Michael DeHaan
45c40524ef Time limit needs to be passed to async_wrapper. 2012-03-03 12:47:31 -05:00
Michael DeHaan
eaa7714ff8 Laying the groundwork for async mode, async status script still needs to be done, and async_wrapper
still needs to daemonize.  Then, once done, playbook can be taught how to poll async within the
timing window.
2012-03-03 12:25:56 -05:00
Michael DeHaan
ab408b0000 Ability to import task lists and handler lists from a top level playbook file. It is possible
to use multiple import statements to implement 'class' like behavior, and also to share
a common list of handlers between multiple patterns.
2012-03-03 10:53:15 -05:00
Michael DeHaan
cbfabcd0fb Add -i, -k, and -M to ansible-playbook CLI to match options in /usr/bin/ansible 2012-03-02 22:54:25 -05:00
Michael DeHaan
e4304a0ac5 Make sure tempdirs are cleaned up after execution steps, fix notifiers, make sure
service module is installed by setup.py
2012-03-02 22:38:55 -05:00
Michael DeHaan
6541f338df add pyflakes target & associated fixes. Also decided to save JSON to --tree file so it can
be better used programatically.  May have to come up with another system of tree logging for
playbook if playbook decides to have tree logging.  Presumably not the highest priority.
2012-03-02 22:10:51 -05:00
Michael DeHaan
3ad9db4966 Some minor from 'pep8', and silencing the PEP8 messages I don't care about.
Also make pep8 show all messages rather than just 1 per code.
2012-03-02 22:03:03 -05:00
Michael DeHaan
0d7a84d591 Some minor refactoring of playbook code, more to go. 2012-03-02 21:43:46 -05:00
Michael DeHaan
c57df6220b Add pydoc to playbook binary, fix default types for playbook '.get()' call 2012-03-02 21:20:37 -05:00
Michael DeHaan
34cbbfbfe1 Added pydoc for utils.py 2012-03-02 21:16:29 -05:00
Michael DeHaan
e9a24cdad4 Extensive refactoring of bin/ansible, moving most output functions into lib/ansible/utils to
encourage readability and make things more maintainable.
2012-03-02 21:08:48 -05:00
Michael DeHaan
e6a1acf756 Let "all" be an alias for "*" in patterns, fix output bug on non-command execution, make clean now removes the build dir 2012-03-02 19:44:50 -05:00
Michael DeHaan
5040c01640 rename 'pattern' to 'hosts' in playbook format. 2012-03-01 22:20:45 -05:00
Michael DeHaan
687a315a80 Increasing default --forks to 5 2012-03-01 22:19:41 -05:00
Michael DeHaan
847846af0e -p has been replaced by a required option. Various docs changes. 2012-03-01 22:10:47 -05:00
Michael DeHaan
bed29b7e11 Allow the /etc/ansible/hosts file to contain groups and those group names to be used in place
of pattern names.
2012-03-01 20:41:17 -05:00
Christopher Johnston
d15172abdc add a -T option for setting ssh timeout in seconds 2012-03-01 16:54:17 -08:00
Christopher Johnston
2773234c3f python 2.5 does not include json so lets try to use simplejson 2012-02-29 09:30:02 -08:00
Michael DeHaan
ab266472be Trim errors on connection refused messages 2012-02-28 04:23:34 -05:00
Michael DeHaan
a40ac93716 Plan to merge things back into ansible means we can simplify our code tree
by eliminating the lib/ansible/scripts file.  Ansible-playbook
doesn't have enough options to need it's own thing, and we're going to try
to work most things back into bin/ansible
2012-02-28 04:20:25 -05:00
Michael DeHaan
430f38d54c minor option consistency 2012-02-28 02:41:32 -05:00
Michael DeHaan
ab17f6f44e Because I can't remember which options are supposed to be uppercase and which are not,
rename all of them so we can use non-conflicting lowercase.  Manpage updates pending
2012-02-28 02:38:36 -05:00
Michael DeHaan
de1d0011bc Take darkened hosts out of the playbook rotation, fix error handling in template
module so that if a directory path is specified we get valid output
2012-02-28 02:32:14 -05:00
Michael DeHaan
01e5da6d0b Make /bin/ansible use the common options from lib/ansible/scripts
DRY!
2012-02-28 01:33:22 -05:00
Michael DeHaan
fb531a8dfa Minor option string relabelling, move one option from common into helper script 2012-02-28 01:01:44 -05:00
Michael DeHaan
7de661dd2c Add ansible command, fix import error in runner 2012-02-28 00:45:37 -05:00
Michael DeHaan
0321afb1e3 Minor error handling tweaks (yell if no args) for ansible-command and some minor
style bits (underscores between compound words, use dest always in optparse)
2012-02-28 00:28:43 -05:00
Michael DeHaan
a3a426b4c5 Add GPLv3 license headers to new files. Approved by all contributors on mailing list. 2012-02-28 19:09:30 -05:00
Michael DeHaan
5eea593af5 Merge branch 'master' of github.com:mpdehaan/ansible 2012-02-28 19:08:37 -05:00
Michael DeHaan
be4cb64c92 Relicensing to GPLv3, all previous committers ok'd on mailing list. 2012-02-28 19:08:09 -05:00
Michael DeHaan
0ed3e87792 Merge pull request #40 from skvidal/master
ans-command
2012-02-28 04:14:15 -08:00
Seth Vidal
95706af074 ans-command and scripts.py for the basic cli parser to be imported elsewhere 2012-02-28 01:12:04 -05:00
Michael DeHaan
1caafb7bd9 Stop evaluating a host in a playbook when it encounters the first failure. 2012-02-27 22:28:01 -05:00
Seth Vidal
85f751175d - make tmp_path be a dir so we can put more than one command in there securely 2012-02-27 17:52:37 -05:00
Seth Vidal
bd7a71bb29 implement manual multiprocessing pools for the runner.
this fixes the ctrl-c not-working problem.

implemented this solution: http://www.bryceboe.com/2010/08/26/python-multiprocessing-and-keyboardinterrupt/#georges

also add hosts which do not get a chance to return results to the 'dark' results.
2012-02-27 00:43:02 -05:00
Seth Vidal
1a20b00d1f If the error is an authentication exception - just report it that way don't dump out an unappetizing traceback which just says the same 2012-02-26 22:59:45 -05:00
Michael DeHaan
f7cff27f3d Drastically simply playbook syntax 2012-02-26 20:54:51 -05:00
Michael DeHaan
fc4ba46d1a Add a ton of comments so folks can understand what runner does. More refactoring is
certaintly possible too.
2012-02-26 20:29:27 -05:00
Michael DeHaan
c0ac0e9b62 Added comments to explain the playbook code. 2012-02-26 20:18:42 -05:00
Michael DeHaan
78a254fc52 In playbooks, each pattern stanza can reference it's own user to run as, so you can
run things as multiple sets of users (if you want) in the same playbook.
2012-02-26 19:58:56 -05:00
Michael DeHaan
61d064d011 Fixed up KV munging in runner, misc fixes to copy, setup, and template modules 2012-02-26 19:55:26 -05:00
Michael DeHaan
e5f62f20b1 make copy & template module take key/value parameters so we're consistent. Only the command
module works differently now

starter manpage for modules

allow template file location to be passed into template & setup modules
2012-02-26 19:21:44 -05:00
Michael DeHaan
deb71da91e trim md5sum string so it does not contain the filename
also fix a bug/typo in the reporting from playbook
2012-02-26 12:10:57 -05:00
Michael DeHaan
d308254eae A basic service module with 'ensure' idempotence semantics. Playbook updated to use service
module vs command module for restarting.  May be some bugs and requires the service to implement 'status' -- and probably some better error handling (i.e. return JSON with "failed" element if failed).

Improvements welcome.
2012-02-25 20:27:11 -05:00
Michael DeHaan
cb90df2377 Allow multiple patterns to specified, just like Func did. 2012-02-25 17:22:48 -05:00
Michael DeHaan
b44ae0af90 applying indentation patch from skvidal 2012-02-25 17:16:23 -05:00
Michael DeHaan
a5039eec62 Update reporting on playbook runs. 2012-02-25 15:21:11 -05:00
Michael DeHaan
79fdc1b6f4 Notifable handlers only run when something is changed. Awesome. 2012-02-25 14:42:41 -05:00
Michael DeHaan
de80166b6d Misc refactoring, updated TODO to reflect new templating features being completed 2012-02-05 13:25:10 -05:00
Michael DeHaan
ba9468266f Can it get an easier? Yes it can! Further simply playbook format. 2012-02-05 13:05:09 -05:00
Michael DeHaan
6d0fd2bfde Compress the playbook format for readability 2012-02-05 12:52:07 -05:00
Michael DeHaan
b053df4182 Some refactoring of runner.py -- more to come to eliminate repeated code 2012-02-05 12:48:52 -05:00
Michael DeHaan
6cceaa5f6a Implment copy with an actual minion-side module such that we can get md5sum's and
onchange events like Puppet's file providers do.
2012-02-24 05:15:28 -05:00
Michael DeHaan
440bac4a95 Added remote templating engine using jinja2, see examples/playbook.yml for usage.
Cleanup is due in runner.py
2012-02-24 04:35:51 -05:00
Michael DeHaan
5d6b0280d5 Added stub for template execution, WIP. 2012-02-24 03:45:36 -05:00
Seth Vidal
160470bc49 - add match_hosts() method to runner.Runner()
- add pattern parameter to self._matches() and match_hosts() so you can query
  for matches against the host list
- these are useful when writing scripts and you want to tell the user
  what hosts you will be running on before  actually executing anything.
2012-02-25 01:06:18 -05:00
Seth Vidal
e7bb41ff89 simple logging setup using logger.
/usr/bin/logger should probably be a constant or defined in some sort of config as well as the log priority
2012-02-24 23:25:30 -05:00
Michael DeHaan
e25bb2f888 Upgrade output for playbook runs 2012-02-24 02:36:38 -05:00
Michael DeHaan
ee2fa721f1 Kinda have to pass the host list parameter 2012-02-24 02:14:22 -05:00
Michael DeHaan
43f7dee247 Added rough sketch of what I want for playbook support. Debug heavy at the moment
as I figure out how logging/output might look.  A couple of major TODO features
also listed in the file.
2012-02-24 01:02:24 -05:00
Michael DeHaan
d079c8e5f3 Move runner out of __init__.py so it's clear what classes live where. 2012-02-23 23:28:58 -05:00
Michael DeHaan
6eda2cf383 Added initial stub for where playbooks will go, moved to common
constants file so as to not repeat constants between CLI and lib.
2012-02-23 23:26:16 -05:00
Michael DeHaan
b2e8084c50 Merge pull request #4 from skvidal/master
adds an option to ask for and store the ssh password from the cli
2012-02-24 15:27:19 -08:00
Seth Vidal
08b45d6da1 add support to prompt for ssh password on the cli 2012-02-24 18:13:11 -05:00
Jeremy Katz
25df80ff58 Use a mktemp'd path for uploading modules 2012-02-24 15:51:16 -05:00
Michael DeHaan
bd37864242 Comments and fixup on the dark/contacted code 2012-02-23 23:00:37 -05:00
Michael DeHaan
11f7930038 trim unused modules 2012-02-23 22:54:01 -05:00
Michael DeHaan
7be8d134c9 Rename 'successful' to 'contacted' ... 2012-02-23 22:47:03 -05:00
Michael DeHaan
530e54b3e4 Fix multiprocessing pool usage and remove stackoverflow hack 2012-02-23 22:38:51 -05:00
Michael DeHaan
7ce5db97ed Add explicit calls to close connections 2012-02-23 22:10:34 -05:00
Michael DeHaan
e0e98d10ce use readlines on stdout so we'll block on long running commands 2012-02-23 22:09:23 -05:00
Michael DeHaan
7eb2dd2dee Add remote setting to file, update TODO 2012-02-23 22:04:09 -05:00
Michael DeHaan
3da6370a65 use defaults better, improve/fix setup.py 2012-02-23 21:37:39 -05:00
Michael DeHaan
9681e1fa04 Add MIT license headers 2012-02-23 19:42:05 -05:00
Michael DeHaan
3807824c6d Added file copy support w/ readme updates 2012-02-23 16:07:10 -05:00
Michael DeHaan
145a024d7b Split CLI into binscript 2012-02-23 14:56:14 -05:00
Michael DeHaan
f31421576b Genesis. 2012-02-23 14:17:24 -05:00