Michael DeHaan
d2721526de
Small tweak, don't merge conditionals, just evaluate each in turn.
2013-06-19 21:18:05 -04:00
George Miroshnykov
c642ba77ae
Added basic support for hash_behaviour=merge in roles
...
Dict vars passed to roles are now properly merged
instead of simply overriding dict vars that are
coming from vars_files.
2013-06-19 09:14:20 +03:00
Michael DeHaan
132c89e681
Merge branch 'callbackinit' of git://github.com/sergevanginderachter/ansible into devel
2013-06-18 20:52:43 -04:00
David Golden
d65f45f0b2
Expand sudo_user after variable merging
...
Previous commit c3659741
expanded sudo_user during task construction,
but this is too early as it does not pick up variables set during
the play.
This commit moves sudo_user expansion to the runner after variables
have been merged.
2013-06-14 09:59:31 -04:00
Serge van Ginderachter
2a7f9df109
add support for callback_plugins/ relative to playbook
2013-06-12 23:54:00 +02:00
Chris Church
3f17a39238
Set current play/task to None for callback context when finished running the current play/task.
2013-06-09 12:17:57 -04:00
Kent Frazier
4c6583bd00
Fix bug with include-level vars and sudo_user.
...
If a variable was provided for an include, in either of these ways:
---
- hosts: all
tasks:
- include: included.yml param=www-data
- include: included.yml
vars:
param: www-data
and then that param was used as the value of sudo_user in the included
tasks:
---
- name: do something as a parameterized sudo_user
command: whoami
sudo: yes
sudo_user: $param
you would receive a "failed to parse: usage: sudo" error back and the
command would not execute.
This seemed to be due to a missing call to template.template somewhere,
because the final value being passed through ssh was still `$param`.
After some digging, the issue seems to instead have been a problem with
providing the wrong context to the template for expansion. Inside the
`Task` logic, it was passing `play.vars` as the context, where
`module_vars` seemed more appropriate. After replacing it, my test case
above ran without issue. There was a comment above suggesting that the
template call might be unnecessary, but removing it made the original
error return, since it is not getting escaped later down the line. I
removed the comment since it was inaccurate.
I tried to actually incorporate my test case above into the test suite
as a regression test, but was unable to figure out how to structure it.
The existing test infrastructure seemed to only be testing for correct
number of counts in things (ok vs. changed, etc.), without regard for
whether the content generated by the command is correct. If there is an
example of a test similar to this one (where I would want to check the
JSON generated to make sure sudo_user had been converted), please let me
know and I will be happy to submit an additional patch.
2013-05-23 00:05:11 -05:00
Tim Habermaas
4d24faeeb1
Fix grammatical error in error message
2013-05-13 13:22:57 +02:00
Michael DeHaan
7117ca5395
Allow modules in a "./library" directory to be referenced by their shortforms "modulename:" instead of just "action: modulename"
2013-04-28 21:05:19 -04:00
Michael DeHaan
a81089231e
Register skipped tasks so we can at least check their changed/not-changed status.
2013-04-28 10:13:58 -04:00
Stoned Elipot
75b51f79b4
Add module path library/ if it exists in role directory
2013-04-27 18:43:56 +02:00
Michael DeHaan
75cf5c985b
Allow playbook tags to be comma seperated strings as well as lists
2013-04-27 12:29:32 -04:00
Matt Coddington
c83c534a7d
Search for roles in the roles subdir first. Throw an error when no role .yml files are found.
2013-04-25 22:40:04 -04:00
Michael DeHaan
5af271911b
Fix duplicate handler notification issue in 1.2 devel
2013-04-25 21:24:15 -04:00
Michael DeHaan
21fe750cef
Flush handlers before pre and post task sections change, but not between task and roles, as this seems
...
to be confusing to people (and not usually neccessary)
2013-04-24 22:28:06 -04:00
Michael DeHaan
6fdfbb1a34
Improve variable smushing so it only has to be done in one place. This is related to shlex.split being called
...
on untemplated variables in some rare cases.
2013-04-24 22:00:40 -04:00
Michael DeHaan
6c778acd91
Smush the braces in various places (hey, that rhymes) to avoid undo key=value splitting surprises
...
in new template system.
2013-04-22 22:05:06 -04:00
Michael DeHaan
3e0c33c1fa
Empty plays should still gather facts
2013-04-21 17:35:09 -04:00
Michael DeHaan
b08181e9b4
Merge pull request #2731 from stoned/flush_handlers-cleanup
...
handlers must be run once
2013-04-21 14:14:04 -07:00
Michael DeHaan
08324cb5d7
Allow play tagging in context of new meta-tasks.
2013-04-21 17:12:12 -04:00
Stoned Elipot
747c7f0dff
handlers must be run once
...
so remove all occurences of each host from the handlers notified by
lists
2013-04-21 17:23:13 +02:00
Michael DeHaan
32fb6c807c
Allow handlers to run in between pre_tasks, roles, tasks, and post_tasks.
2013-04-20 18:03:03 -04:00
Michael DeHaan
37789a852a
Rename set_up and tear_down to pre_tasks and post_tasks
2013-04-20 16:19:01 -04:00
Michael DeHaan
d7623d1f91
Added a 'set_up' and 'tear_down' which are like tasks, but execute before and after roles.
2013-04-20 16:07:06 -04:00
Michael DeHaan
53ac0bbec2
Instantiate callback plugins only once so we can set play/task objects on them and they'll stick.
2013-04-20 09:09:35 -04:00
Michael DeHaan
d8bf87b008
(A) include errors in inventory scripts should they occur.
...
(B) allow registration with ignore_errors: True
2013-04-17 22:27:00 -04:00
Michael DeHaan
7c6341718e
Merge branch 'combine_vars' of git://github.com/laggyluke/ansible into exp
...
Conflicts:
lib/ansible/inventory/vars_plugins/group_vars.py
lib/ansible/runner/__init__.py
lib/ansible/utils/__init__.py
test/TestPlayBook.py
2013-04-16 20:06:06 -04:00
Michael DeHaan
0944e7d56a
Make less template calls on playbook objects.
2013-04-12 21:48:01 -04:00
Michael DeHaan
44a9352338
Also template handlers only at the end.
2013-04-12 20:32:35 -04:00
Michael DeHaan
e7f5186dec
Merge pull request #2623 from willthames/when_set_bug
...
Prevent premature variable substitution in tasks
2013-04-12 17:19:25 -07:00
Michael DeHaan
3ab0ed5fd4
Allow 'when' and 'with_items' to be applied to roles.
2013-04-12 19:02:56 -04:00
willthames
377bc31311
Prevent premature substitution of variables into tasks
...
As documented in #2623 , early variable substitution causes when_
tests to fail and possibly other side effects.
I can see the reason for this early substitution, likely introduced
in 1dfe60a6
, to allow many playbook parameters to be templated.
This is a valid goal, but the recursive nature of the utils.template
function means that it goes too far.
At this point removing tasks from the list of parameters to be
substituted seems sufficient to make my tests pass. It may be the
case that other parameters should be excluded, but I suspect not.
Adding a test case. I would prefer to analyse not just the aggregate
statistics but also whether the results are as expected - I can't
see an easy way to do that with the available callbacks at present.
2013-04-12 09:17:03 +10:00
Michael DeHaan
7931597a6a
Fix template call.
2013-04-11 12:15:13 -04:00
Michael DeHaan
b09ef21ec9
Add code to flag legacy templating like $foo.{bar} as deprecated in favor of Jinja2 {{ foo.bar }} so we
...
can remove the legacy system at a later date.
2013-04-10 17:52:35 -04:00
Michael DeHaan
29209c4913
Style fixes so "make pep8" is clean.
2013-04-10 16:37:49 -04:00
Michael DeHaan
c5d9823467
Fix some items related to playbook includes and indentation.
2013-04-10 15:04:41 -04:00
Michael DeHaan
290780d13f
Playbook + with_items was an undocumented feature that was causing problems because it would
...
evaluate and replace '$item' with ''. Really it doesn't make sense to include multiple playbooks
via a loop variable, as you can do this with task + with_items already (and it's a simpler code
path). Given this is undocumented, this removes that feature, and we'll consider next how to
also add 'with_items' support directly to roles.
2013-04-09 20:13:55 -04:00
Michael DeHaan
c64f19dc5f
Don't set the item variable as eager template replacement will over-replace the variable as an empty string.
2013-04-09 19:57:53 -04:00
willthames
9d87733f98
Test case and fix for shlex.split unicode bug
...
When operating on a unicode string in python 2.6, shlex.split returns
a result that does not work with the file constructor.
To reproduce this requires a task include that is templated (this is
because the templated string is a unicode result, whereas a non-
templated string is a non-unicode string)
[will@centos6.3] $ python
Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shlex
>>> shlex.split(u'abc')
['a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00']
[will@fedora17] $ python
Python 2.7.3 (default, Jul 24 2012, 10:05:38)
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shlex
>>> shlex.split(u'abc')
['abc']
The proposed fix (coercing the include parameters to string before the
shlex.split) may not be ideal but it does fix the bug for my test case.
2013-04-08 14:47:43 +10:00
Michael DeHaan
61f2668b0a
Don't include the '.yml' in the path to the retry files.
2013-04-08 12:38:05 -04:00
Michael DeHaan
0d530f3bf0
Change the retry logic to write a limit file, able to source limit from files by indicating with @filename
2013-04-08 12:36:01 -04:00
Michael DeHaan
c695aa2d6a
When playbooks fail, attempt to create an inventory file in the inventory directory that allows rerunning
...
of the playbook against only the hosts that failed.
2013-04-07 23:37:10 -04:00
Stoned Elipot
1ed54b9b3a
when: condition support for tasks include
2013-04-07 00:43:39 +02:00
Michael DeHaan
fffb1a0a9d
Loose tasks not in roles get executed after roles.
2013-04-06 18:36:25 -04:00
Michael DeHaan
f044fc344b
When using roles, or other includes, the path to DWIM inside is the path of the task include
...
file.
2013-04-06 18:32:36 -04:00
Michael DeHaan
5c4ed72571
Demo of parameterized roles!
2013-04-06 12:51:17 -04:00
Michael DeHaan
f308194b9a
Added examples of how roles work!
2013-04-06 12:35:35 -04:00
Michael DeHaan
892484812e
Much requested feature -- allows relative imports of content within roles or relative to any task or handler include (../templates for template ../files for copy)
2013-04-06 12:13:04 -04:00
Michael DeHaan
95f30f0def
Complete streamlining of vars handling in playbooks and how those are templated to avoid
...
repeat template calls at playbook intialization time.
2013-04-06 10:45:09 -04:00
Michael DeHaan
1dfe60a6ea
Allow any parameter in a play to be set by --extra-vars through cleaner use of data structure
...
templating.
2013-04-06 10:09:16 -04:00
George Miroshnykov
6826aa7360
Tweaked merge_hash to also affect Runner behavior
2013-04-06 13:06:38 +03:00
Michael DeHaan
f585c4cde7
Upgraded variable support met with upgraded conditional support, see examples/playbooks/upgraded_vars.yml
...
for details!
2013-04-05 19:10:32 -04:00
Junegunn Choi
b874027b36
compare the number of available hosts before and after running each task
2013-03-29 13:13:22 +09:00
Junegunn Choi
20a48c6bdf
terminate immediately on a failure
2013-03-28 15:17:01 +09:00
Michael DeHaan
42b0e51223
Upgrade callbacks further, now '.play', '.task', and so on are also available!
2013-03-25 22:56:32 -04:00
Michael DeHaan
0d11f53eff
Let the callbacks see the playbook and (current) runner objects.
2013-03-25 22:47:06 -04:00
Michael DeHaan
783a12cc0e
Resolve merge commit.
2013-03-25 22:32:01 -04:00
David Hughes
c365974117
Added variable expansion to task sudo_user parameter
2013-03-15 11:31:27 -07:00
milan
80dbab3cf0
check type of task explicitly
2013-03-14 13:06:55 +01:00
Seth Vidal
7687c2caf8
add --step option to ansible-playbooks to let people step through a playbook
...
one by one - asking for confirmation along the way.
also allows to 'continue' after a certain point
2013-03-11 00:39:05 -04:00
Daniel Hokka Zakrisson
297259725a
Allow (local_)action: to be a dict
...
Use the key module: to set which module to invoke.
2013-02-28 14:12:36 +01:00
Daniel Hokka Zakrisson
c04d5ba739
Allow specifying args directly to actions using module: syntax
...
Makes things like
- name: do complex things with complex module
complex:
setting_a: true
setting_b:
- foo
- bar
possible.
Fixes #2228 .
2013-02-28 13:54:04 +01:00
Daniel Hokka Zakrisson
7e0ee6809c
Don't template delegate_to too early, not all vars are available
...
Fixes using delegate_to: $item within a playbook include.
2013-02-25 22:25:13 +01:00
Michael DeHaan
9cf66f4376
Fixes from 'make pep8'. Partial, more to come.
2013-02-17 19:40:38 -05:00
Michael DeHaan
1ecf4a6943
Working on complex argument support.
2013-02-17 15:01:49 -05:00
Michael DeHaan
c8878998d1
update some of many copyright dates but we can just do this when editing each file, not super high priority
2013-02-16 15:32:01 -05:00
Daniel Hokka Zakrisson
57e51f7fdf
Clean up some extra_vars redundancy
2013-02-11 23:25:50 +01:00
Michael DeHaan
f7497e75e5
Able to use "environment: " on any task to pass proxy details and other useful settings. Can be a variable
...
or a dictionary.
2013-02-10 13:05:58 -05:00
Michael DeHaan
a9162a86f2
Very basic --diff option for showing what happens when templates change.
...
Probably output is not useful if not used with --limit
Works well with --check mode
2013-02-07 22:52:25 -05:00
Daniel Hokka Zakrisson
98f0a9210e
Raise an error when multiple when_* statements are provided
...
Fixes #1994 .
2013-02-07 08:11:30 +01:00
Daniel Hokka Zakrisson
d5e63332fe
Raise an error if an action doesn't have a string type
...
Happens with e.g. "command: true" that YAML helpfully converts to a
bool.
2013-02-06 16:41:34 +01:00
Michael DeHaan
fed82c2188
This implements a basic --check mode which for now is only implemented on template & copy operations. More detail will be shared with the list
...
shortly.
2013-02-03 20:34:13 -05:00
Daniel Hokka Zakrisson
a025cfcb33
Add on_import_for_host callback from non-list case
2013-02-03 23:37:29 +01:00
Daniel Hokka Zakrisson
a79373f6b2
Make template_ds the only templater
...
Instead of having to remember when to use which one, rename template_ds
to template and move the last bit of code from template to varReplace
(which gets used for all string replacements, in the end).
This means that you can template any data type without worrying about
whether it's a string or not, and the right thing will happen.
2013-02-03 14:01:54 +01:00
Daniel Hokka Zakrisson
f7e286cf34
Fix error format for invalid vars_files
2013-01-31 20:25:28 +01:00
Seth Vidal
83b9654c63
stop updating SETUP_CACHE in run_play as per comment on pr 1945
2013-01-31 11:24:22 -05:00
Seth Vidal
f649777072
- make extra-vars override all other vars and facts in playbooks
2013-01-30 11:56:04 -05:00
Michael DeHaan
0030a2bd09
Allow handler files to be empty lists.
2013-01-27 10:40:29 -05:00
Daniel Hokka Zakrisson
94a1c221bc
Update variable precedence section with current rules
2013-01-22 16:56:04 +01:00
Rodney Quillo
395093e0bf
Move default arguments to the end of the function call.
2013-01-19 08:34:47 +08:00
Rodney Quillo
7ae100611c
Adding default on vars_prompt
2013-01-18 19:00:57 +08:00
Daniel Hokka Zakrisson
4d48daff80
Actually allow using connection: on a task
2013-01-06 18:46:34 +01:00
Daniel Hokka Zakrisson
caee51e90e
Allow only_if/when_* on task includes and apply it on all tasks within
2013-01-04 00:15:13 +01:00
Daniel Hokka Zakrisson
07b215d4fa
Check for non-accepted arguments combined with task includes
...
Throw an appropriate error for it.
2013-01-03 23:36:42 +01:00
Daniel Hokka Zakrisson
68f736e8d7
Make inventory variables available to vars_files
2013-01-03 23:16:38 +01:00
Daniel Hokka Zakrisson
a1877b2213
Allow infinite depth task includes
2013-01-03 23:01:04 +01:00
Daniel Hokka Zakrisson
4555cdc49c
Allow using connection: on the task level
...
This is the name of the setting on the play level, and the options.
Should be consistent.
2013-01-03 21:27:01 +01:00
Daniel Hokka Zakrisson
3a36c024da
Make lookups being fatal up to the caller
...
Fixes #1769 .
2012-12-19 19:19:04 +01:00
Daniel Hokka Zakrisson
97cc384ccf
Set basedir to . if there isn't one
...
This avoids special-casing '' = '.' everywhere the basedir gets used.
Fixes #1729 .
2012-12-19 13:22:57 +01:00
Daniel Hokka Zakrisson
c2792a936d
Allow parameterized playbook includes to define complex variables
...
To be used like:
- include: playbook.yml
vars:
mylistvar:
- item1
- item2
2012-12-15 21:56:28 +01:00
Nandor Sivok
f31fbdff1f
moving int() conversion to the play init
2012-12-14 18:05:08 +01:00
Nandor Sivok
e91db5fcdc
fixes #1767 parsing serial from extra_vars
2012-12-14 13:21:58 +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
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
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
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
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
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
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
Daniel Hokka Zakrisson
3ce63d845e
remote_port is None by default
2012-11-21 14:10:10 +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
f95fefd8c5
Use plugin system to find modules
2012-11-18 19:09:21 +01: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
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
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
0ca1775bda
Try to ensure the entire value is quoted
2012-11-13 02:40:29 +01: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
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
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
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
Daniel Hokka Zakrisson
e05e514861
Create a plugin loader system
2012-11-02 01:24:14 +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
Michael DeHaan
c0747b7baa
pep8 fixes
2012-10-30 20:42:07 -04:00
Daniel Hokka Zakrisson
e72fdccd87
Allow vars_files sequences without a default
2012-10-28 16:35:22 +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
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
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
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
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
Aleksej Romanov
c5469f6367
Vars specified via CLI have the highest priority.
2012-10-16 04:34:54 +07: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
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
Michael DeHaan
f3d7294690
Test for directory existance, fix exception catching granularity
2012-10-11 07:56:01 -04: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
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
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
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
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
Daniel Hokka Zakrisson
8a8ffa2342
Allow task includes to work with with_items
2012-09-30 13:40:52 +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
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
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
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
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
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
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
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
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
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
Daniel Hokka Zakrisson
7a201dbb2e
Keep result pristine for ignore_errors
2012-09-04 22:40:07 +02:00
Michael DeHaan
00c4c5c4a1
If tags "all" is used, don't choke.
2012-08-28 20:33:36 -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
Michael DeHaan
2833f48ed3
Make a particular error about an invalid include statement a bit clearer.
2012-08-21 22:08:08 -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
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
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
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
Michael DeHaan
de221e6b4b
Add vars to host_vars to prevent some suprises
2012-08-14 20:35:01 -04:00
Michael DeHaan
6de8c27085
Load parent groups when processing group_vars
2012-08-14 19:48:33 -04:00
Dave Peticolas
b42e835aab
Always load group_vars and host_vars.
2012-08-13 21:08:05 -07:00
Michael DeHaan
72faf8eb0a
fix indents
2012-08-11 12:20:16 -04: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
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
Rodney Quillo
d1f821361d
vars_prompt encrypt from mgw
2012-08-09 22:56:40 +08:00
Michael DeHaan
846186e2fc
Add -vvv support for debugging activity
2012-08-08 21:09:14 -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
b76efa39be
Fix some templating issues, needs testing with anti-unicode safeguard around shlex.split
2012-08-02 20:21:59 -04:00