Commit Graph

291 Commits (9c49fdd86d0f555dd1bef0d117e095ca1287047f)

Author SHA1 Message Date
James Cammarata 71867f9480 Remove vars attribute from base
Fixes #11779
11 years ago
James Cammarata 7bc789ba64 Properly template task names
Also fixes in the correct way the bug in which the role name was
incorrectly showing up twice in the task name.

Fixes #10347
11 years ago
James Cammarata 975172c1ef Make sure role name doesn't end up in task name more than once
Fixes #11691
11 years ago
James Cammarata 66a8864ae9 Fix environment setting and inheritence
Fixes #11401
11 years ago
James Cammarata e64989beb4 Moving ConnectionInformation -> PlayContext
Also making PlayContext a child class of the Playbook Base class,
which gives it access to all of the FieldAttribute code to ensure
field values are correctly typed after post_validation

Fixes #11381
11 years ago
James Cammarata f68223b9ed Don't add module args into variables at all
Getting recursive errors otherwise, so this is probably not something
we want to do. This most likely only worked in v1 due to the fact that
module args were templated earlier than the point in Runner() when
they were fed into the templating engine.
11 years ago
James Cammarata 332ca927d9 Fix parent attribute lookup
Using 'value is None' instead of 'not value', in order to account
for boolean values which may be false

Fixes #11232
11 years ago
James Cammarata 72d4b40a26 Don't allow empty (none) loop values
Fixes #8593
11 years ago
James Cammarata aa53212a9b Don't use all task params for vars, just the module args 11 years ago
James Cammarata 803fb397f3 Fixing filter plugins directory from switch 11 years ago
James Cammarata ce3ef7f4c1 Making the switch to v2 11 years ago
James Cammarata f4172fb9da Fix tag handling on meta:flush_handlers tasks
Fixes #10758
11 years ago
Brian Coca fd2d7fe447 Merge pull request #10290 from bcoca/remove_bare_warning
removed bare variable detection as this confuses people
11 years ago
Brian Coca de5eae2007 fixed traceback when x_user implicitly sets the become method
Fixes #10430

Also removed redundant resolution of sudo/su for backwards compatibility which
confused the conflict detection code.
11 years ago
Brian Coca 5f6db0e164 preliminary privlege escalation unification + pbrun
- become constants inherit existing sudo/su ones
- become command line options, marked sudo/su as deprecated and moved sudo/su passwords to runas group
- changed method signatures as privlege escalation is collapsed to become
- added tests for su and become, diabled su for lack of support in local.py
- updated playbook,play and task objects to become
- added become to runner
- added whoami test for become/sudo/su
- added home override dir for plugins
- removed useless method from ask pass
- forced become pass to always be string also uses to_bytes
- fixed fakerunner for tests
- corrected reference in synchronize action plugin
- added pfexec (needs testing)
- removed unused sudo/su in runner init
- removed deprecated info
- updated pe tests to allow to run under sudo and not need root
- normalized become options into a funciton to avoid duplication and inconsistencies
- pushed suppored list to connection classs property
- updated all connection plugins to latest 'become' pe

- includes fixes from feedback (including typos)
- added draft docs
- stub of become_exe, leaving for future v2 fixes
11 years ago
Brian Coca c81d981164 Merge pull request #10183 from bcoca/tag_control
adds complex tag management
11 years ago
Toshio Kuratomi 920b71984e lists => frozenset as we're only using them in membership checks 11 years ago
Brian Coca 7044b5a8d1 removed bare variable detection as this confuses people and forced us to allow for bare expressions 11 years ago
Brian Coca 95fa770ba0 adds complex tag management
Adds a special tag:
 - always: always runs no matter what --tags, --skip-tags say

Adds 4 special keywords for --tags/skip-tags
 - all: all tagged + untagged tasks
 - tagged: only tagged tasks
 - untagged: only untagged tasks
 - always: only run tasks tagged 'always'
11 years ago
Kishin Yagami ac4dc1f739 enable environment keyword at play level 11 years ago
James Cammarata 4b6b58ab11 Fix role parameter precedence after 9a0f8f0
Fixes #9497
11 years ago
James Cammarata 9a0f8f0158 Split out various vars-related things to avoid merging too early
Fixes #9498
11 years ago
Toshio Kuratomi cf548baeab Fix missing strip() in a1809a371a 11 years ago
Toshio Kuratomi a1809a371a Target unnecessary templating warning at lines consisting of a single variable
Fixes #6407
11 years ago
James Cammarata 8a5675ca9f Fixing no_log for the playbook level use
Fixes #8647
11 years ago
James Cammarata 20957a1b85 Remove duplicate compiling of task when: statements
Fixes #8538
12 years ago
James Cammarata a650421e39 Catch task parameter splitting errors nicely
Fixes #8481
12 years ago
Michael DeHaan 8c4161d4a1 Merge branch 'retf_py' of git://github.com/berendt/ansible into devel
Conflicts:
	lib/ansible/inventory/vars_plugins/group_vars.py
	plugins/callbacks/mail.py
12 years ago
James Cammarata e19ed3424d Make sure default vars are used in template calls for tasks
Fixes #8499
12 years ago
James Cammarata 80df2135e9 Fix parsing of tasks with variable module names
Also adding an integration test for same.
12 years ago
James Cammarata b21875d5a9 Make sure 'item' variable is set when using first_available_file
Fixes #8220
12 years ago
Matt Martz 0e953c2863 Add run_once task key
This caused the task to act like  bypass host loop plugin and
execute only on a single host. Can be used with delegate_to
12 years ago
Christian Berendt 6676720ce5 fixed typos found by RETF rules in PY files
rules are avaialble at https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Typos
12 years ago
Michael Scherer 1e34e95ba0 Improve error message when multiple action are given
This can be illustrated using this playbook:

    - command: id
      delegate_to: "{{ remote_server }}"
      user: "{{ remote_user }}"

The error is to use 'user' instead of 'remote_user', but the error message
do not really mention it, so it can be a bit hard to spot.
12 years ago
James Tanner 14499e8bf3 Fixes #4325 allow async and poll parameters to be templated vars 12 years ago
Seth Woodworth 1d5db30067 Updates loop warning, removes unnecessary c 12 years ago
James Cammarata 75e3b59bbd Adding no_log: capability for tasks
Fixes #4088
12 years ago
Michael DeHaan d07a3b5e9b AnsibleWorks -> Ansible 12 years ago
jctanner b2d594d24e Merge pull request #5724 from angstwad/su-tasks-fix
Fix bug where playbook tasks do not escalate privs with 'su'
12 years ago
Paul Durivage e875089eba Fix bug where self.su was being set by the sudo param in play tasks 12 years ago
Paul Durivage 01d1bd61e7 Disallow su and sudo params in same play/task 12 years ago
Paul Durivage f72f5a20df Revert "Revert "Merge pull request #5325 from angstwad/add-su-support""
This reverts commit c17d0e0357.

Conflicts:
	lib/ansible/runner/connection_plugins/paramiko_ssh.py
12 years ago
James Tanner c17d0e0357 Revert "Merge pull request #5325 from angstwad/add-su-support"
This reverts commit 6f4bfa2cff, reversing
changes made to c91ba3a7c7.
12 years ago
Paul Durivage dec9131735 Ensure playbook support for su params 12 years ago
Paul Durivage 4088243deb Proposing fix for Issue #4324; adding support for su in connection plugins ssh, ssh_alt
Fixes for ssh_alt support, adding in references to in_data where appropriate
12 years ago
Michael DeHaan 10350d1639 Update various copyrights. Not complete, but sufficient. 12 years ago
Michael DeHaan 8e5b7d3095 Remove code underlying when_* and only_if, which are deprecated features slated for removal in the 1.5 release. 12 years ago
Michael DeHaan 28b9fd4e30 We have had only_if, when_foo, etc, deprecated for a while and said they would be removed in 1.5. Now they are, with friendly error messages still.
Users of these features should use "when:" as documented at docs.ansible.com.

Similarly, include + with_items has been removed.  The solution is to loop
inside the task files, see with_nested / with_together, etc.
12 years ago
James Tanner 4f13967386 Fixes #4536 Get the remote_user from multiple sources in a preferred order 12 years ago
Michael DeHaan 60944b81f0 Provide warning about "with_items: '{{ loop }}'" being redundant only when {{ starts the expression value. Fixes #4582. 12 years ago
Michael DeHaan 21d4400c96 Misc pep8 fixes 12 years ago
jctanner 69fa5954fd Merge pull request #3932 from jocelynj/devel
Add option remote_user to task level, to specify the ssh login user
12 years ago
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. 12 years ago
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
12 years ago
Michael DeHaan 709ffda3d1 Tweak only_if deprecation detector. 12 years ago
Michael DeHaan a45494a896 Add warnings feature. 12 years ago
Michael DeHaan 9637f620d7 Deprecation warnings of several flavors, nice and purple and can be disabled
in ansible.cfg.
12 years ago
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
12 years ago
bennojoy 53e48b63a9 dountil feature commit 1 12 years ago
James Cammarata 27e8675277 Make the role_name in the task its own field for use in the callback 12 years ago
James Cammarata a5ee6ff1e5 Display parent role name of tasks in the name line
Fixes #4076
12 years ago
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
12 years ago
James Cammarata 02b7b79d7e Re-adding capability of tasks to see a unique view of their own defaults 12 years ago
James Cammarata 637d3070dc Allow default variables to be overridden by inventory variables 12 years ago
Jocelyn Jaubert 4cee6a5435 Add option remote_user to task level, to specify the ssh login user 12 years ago
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.
12 years ago
Stoned Elipot eb45f07ae3 Introduce 'changed_when' keyword to override a task's changed status with the evaluation of a Jinja2 expression 13 years ago
Michael DeHaan d2721526de Small tweak, don't merge conditionals, just evaluate each in turn. 13 years ago
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.
13 years ago
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.
13 years ago
Michael DeHaan 7117ca5395 Allow modules in a "./library" directory to be referenced by their shortforms "modulename:" instead of just "action: modulename" 13 years ago
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.
13 years ago
Michael DeHaan 6c778acd91 Smush the braces in various places (hey, that rhymes) to avoid undo key=value splitting surprises
in new template system.
13 years ago
Michael DeHaan 08324cb5d7 Allow play tagging in context of new meta-tasks. 13 years ago
Michael DeHaan 32fb6c807c Allow handlers to run in between pre_tasks, roles, tasks, and post_tasks. 13 years ago
Michael DeHaan 7931597a6a Fix template call. 13 years ago
Michael DeHaan f585c4cde7 Upgraded variable support met with upgraded conditional support, see examples/playbooks/upgraded_vars.yml
for details!
13 years ago
Junegunn Choi 20a48c6bdf terminate immediately on a failure 13 years ago
David Hughes c365974117 Added variable expansion to task sudo_user parameter 13 years ago
Daniel Hokka Zakrisson 297259725a Allow (local_)action: to be a dict
Use the key module: to set which module to invoke.
13 years ago
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.
13 years ago
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.
13 years ago
Michael DeHaan 1ecf4a6943 Working on complex argument support. 13 years ago
Michael DeHaan c8878998d1 update some of many copyright dates but we can just do this when editing each file, not super high priority 13 years ago
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.
13 years ago
Daniel Hokka Zakrisson 98f0a9210e Raise an error when multiple when_* statements are provided
Fixes #1994.
13 years ago
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.
13 years ago
Daniel Hokka Zakrisson 4d48daff80 Actually allow using connection: on a task 13 years ago
Daniel Hokka Zakrisson caee51e90e Allow only_if/when_* on task includes and apply it on all tasks within 13 years ago
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.
13 years ago
Michael DeHaan da90c5f75e Document 'when' and tweak the code to be a little more comprehensive on what is false. 13 years ago
Daniel Hokka Zakrisson 43bdec8b20 Throw an error if multiple actions have been specified 13 years ago
Daniel Hokka Zakrisson 1e0295c7e2 Template handlers late
This allows overriding variables in name, and removes templating from
parsing.
13 years ago
Daniel Hokka Zakrisson d5dd89a8f7 Allow specifying when: ... 13 years ago
Daniel Hokka Zakrisson fd732f8d3b Add when_boolean
Fixes #1567.
13 years ago
Daniel Hokka Zakrisson f95fefd8c5 Use plugin system to find modules 13 years ago
Michael DeHaan 2303f65a1a Merge pull request #1614 from dagwieers/missing-action-error
Print the task name (if any) when complaining
13 years ago
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.
13 years ago
Daniel Hokka Zakrisson 0ca1775bda Try to ensure the entire value is quoted 13 years ago
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.
13 years ago
Daniel Hokka Zakrisson 47082a9171 Add $LOOKUP(<lookup plugin>,<data>) as a templating option
Also moves file and pipe to lookup_plugins.
13 years ago
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.
13 years ago
Daniel Hokka Zakrisson e05e514861 Create a plugin loader system 13 years ago
Michael DeHaan c0747b7baa pep8 fixes 13 years ago
Michael DeHaan 21258dcc66 Added 'when' as a shortcut around only_if. 13 years ago
Michael DeHaan a768e9a9ff Fix for sudo defaults if sudo is passed in via --extra-vars 13 years ago
Daniel Hokka Zakrisson 026e251b94 Make with_items a lookup plugin 13 years ago
Michael DeHaan c5d2f6b0d3 implement lookup plugins for arbitrary enumeration over arbitrary things. See the mailing list for some cool examples. 13 years ago
Michael DeHaan 271db7bddb Merge pull request #1308 from abondis/named_action
named actions + modules list in utils.py
13 years ago
Aurélien Bondis 6d183959ba #1303: add sudo option to tasks 13 years ago
Aurélien Bondis 2063e10c00 named actions + modules list in utils.py 13 years ago
Michael DeHaan f3d7294690 Test for directory existance, fix exception catching granularity 13 years ago
Aurélien Bondis e07bfd9ef8 playbook/tasks: allow to use a module's name instead of action: 13 years ago
Jonathan Palley faed650bb1 allow vars in delegate_to 13 years ago
Jonathan Palley 620accf117 make delegate_to localhost act like local_action 13 years ago
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"
13 years ago
Michael DeHaan b8c4bb9e6e Revert "Allow including files through variables"
This reverts commit bf47bb4753.

Conflicts:

	lib/ansible/utils.py
	test/TestUtils.py
13 years ago
Michael DeHaan 544a8e44d7 Merge pull request #1053 from dhozac/varreplace-include
Allow including files through variables
13 years ago
Daniel Hokka Zakrisson dd11b01350 Keep delegate_to so all auxiliary logic based on that works 13 years ago
Daniel Hokka Zakrisson 5bb0f6908b Allow transport on tasks, and use it for local_action 13 years ago
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"
13 years ago
Tim Bielawa 4121109665 Local actions, they're like aliases for actions with localhost
delegates.

Closes #905
14 years ago
Michael DeHaan f07e55c568 Adds 'delegate_to' as a task option which can be used to signal load balancers and outage windows. 14 years ago
Michael DeHaan 05a128c2be Add ability to store and access module results later on in the play. See examples/playbooks/register_logic for details. 14 years ago
Michael DeHaan faed4b5a33 whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added
in 0.6 release)
14 years ago
Michael DeHaan b76efa39be Fix some templating issues, needs testing with anti-unicode safeguard around shlex.split 14 years ago
Michael DeHaan c192d8a2b2 Revert "Apply templating to module arguments in playbook"
Breaks copy module by introducing unicodeness, among other things

This reverts commit 4fedb17e38.
14 years ago
Michael DeHaan 38ed7ca7df Merge pull request #759 from lorin/error-feedback
If task action is invalid, output the name in error message
14 years ago
Lorin Hochstein aed6ee7f74 Report only name in task error, all on one line 14 years ago
Lorin Hochstein fa9fe9d246 If task action is invalid, output the name and action. 14 years ago
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
14 years ago
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.
14 years ago
Michael DeHaan 8bb8314d10 Inject vars need to pushed further up to make with_items work as desired. 14 years ago
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
14 years ago
Michael DeHaan 1754de3335 Misc code cleanup, mostly whitespace preferences, removing unused imports, plus a few fixes here and there. 14 years ago
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.
14 years ago
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!
14 years ago
Michael DeHaan 83f23ef861 Basic support for tagging tasks and selecting a subset of tasks to run with --tags. 14 years ago
Michael DeHaan 4664e354c3 Get with_items to work with new play/task architecture. 14 years ago
Michael DeHaan ecb944892d Tweaks on previous refactoring of playbook, version bump a 0.4 reference, remove some debug, etc 14 years ago
Michael DeHaan b9b53d1941 Playbook refactoring -- work in progress. 14 years ago