Commit Graph

164 Commits (f6e7381a718cce35ab6ac1b31a1b0f5ef34cb3ef)

Author SHA1 Message Date
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