Commit Graph

242 Commits (479408330ec04df1e4e42ced9b4e917b7449e7cd)

Author SHA1 Message Date
Michael DeHaan 60944b81f0 Provide warning about "with_items: '{{ loop }}'" being redundant only when {{ starts the expression value. Fixes #4582. 2013-10-19 14:24:12 -04:00
Michael DeHaan 21d4400c96 Misc pep8 fixes 2013-10-19 13:03:15 -04:00
jctanner 69fa5954fd Merge pull request #3932 from jocelynj/devel
Add option remote_user to task level, to specify the ssh login user
2013-10-15 06:34:57 -07:00
Michael DeHaan 9ea54fcaaf Fixes a dev branch glitch where a conditional could be applied to multiple tasks. Also improves the errors on parsing bad conditionals to make them less confusing to users. 2013-10-12 17:39:28 -04:00
Michael DeHaan d168c709d5 Fix an issue where the ordering of an include statement is processed ahead of the conditional in the included statement,
which required a redundant check to see if a variable was defined rather than short circuiting.

Fixes #4469
2013-10-11 20:43:58 -04:00
Michael DeHaan 709ffda3d1 Tweak only_if deprecation detector. 2013-10-11 19:12:25 -04:00
Michael DeHaan a45494a896 Add warnings feature. 2013-10-11 19:04:26 -04:00
Michael DeHaan 9637f620d7 Deprecation warnings of several flavors, nice and purple and can be disabled
in ansible.cfg.
2013-10-11 18:37:39 -04:00
Michael DeHaan 5e30cd999c Make it possible to say:
tags: 42

And have the tag be a string, not an int, so --tags matches.

Fixes #4110
2013-10-07 15:19:30 -04:00
bennojoy 53e48b63a9 dountil feature commit 1 2013-09-24 13:59:38 +05:30
James Cammarata 27e8675277 Make the role_name in the task its own field for use in the callback 2013-09-20 15:46:34 -05:00
James Cammarata a5ee6ff1e5 Display parent role name of tasks in the name line
Fixes #4076
2013-09-19 20:44:52 -05:00
Hiroaki Nakamura 2357194b39 Add failed_when module variable.
Implementation note: Ternery operator trick for python prior to 2.5 is used.
(test and [when_true_value] or [when_false_value])[0]
http://stackoverflow.com/questions/394809/ternary-conditional-operator-in-python#comment1466794_394887
2013-09-10 08:34:01 +09:00
James Cammarata 02b7b79d7e Re-adding capability of tasks to see a unique view of their own defaults 2013-09-02 21:37:50 -05:00
James Cammarata 637d3070dc Allow default variables to be overridden by inventory variables 2013-08-29 17:21:28 -05:00
Jocelyn Jaubert 4cee6a5435 Add option remote_user to task level, to specify the ssh login user 2013-08-23 23:20:13 +02:00
Stoned Elipot f0743fc32a Introduce the 'always_run' task clause.
The 'always_run' task clause allows one to execute a task even in
check mode.

While here implement Runner.noop_on_check() to check if a runner
really should execute its task, with respect to check mode option
and 'always_run' clause.

Also add the optional 'jinja2' argument to check_conditional() :
it allows to give this function a jinja2 expression without exposing
the 'jinja2_compare' implementation mechanism.
2013-08-20 23:09:44 +02:00
Stoned Elipot eb45f07ae3 Introduce 'changed_when' keyword to override a task's changed status with the evaluation of a Jinja2 expression 2013-07-14 21:07:45 +02:00
Michael DeHaan d2721526de Small tweak, don't merge conditionals, just evaluate each in turn. 2013-06-19 21:18:05 -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
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
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 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 08324cb5d7 Allow play tagging in context of new meta-tasks. 2013-04-21 17:12:12 -04: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 7931597a6a Fix template call. 2013-04-11 12:15:13 -04: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 20a48c6bdf terminate immediately on a failure 2013-03-28 15:17:01 +09:00
David Hughes c365974117 Added variable expansion to task sudo_user parameter 2013-03-15 11:31:27 -07: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 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
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
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
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 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
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 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 f95fefd8c5 Use plugin system to find modules 2012-11-18 19:09:21 +01: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 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 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
Michael DeHaan c0747b7baa pep8 fixes 2012-10-30 20:42:07 -04: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
Daniel Hokka Zakrisson 026e251b94 Make with_items a lookup plugin 2012-10-25 15:10:33 +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 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
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
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 544a8e44d7 Merge pull request #1053 from dhozac/varreplace-include
Allow including files through variables
2012-09-18 17:53:02 -07: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
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 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 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 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
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
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
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 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 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 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 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
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