Commit Graph

291 Commits (9c49fdd86d0f555dd1bef0d117e095ca1287047f)

Author SHA1 Message Date
James Cammarata 4f0be29d65 Reworking retry/until logic to fix bugs
Prior to this patch, the retry/until logic would fail any task that
succeeded if it took all of the alloted retries to succeed. This patch
reworks the retry/until logic to make things more simple and clear.

Fixes #15697
10 years ago
James Cammarata 6eefc11c39 Make the loop variable (item by default) settable per task
Required for include+with* tasks which may include files that also
have tasks containing a with* loop.

Fixes #12736
10 years ago
James Cammarata ccf646665b Revert "Removing explicit setting of failed/failed_when"
This reverts commit 4e528e9535.
10 years ago
James Cammarata 4e528e9535 Removing explicit setting of failed/failed_when 10 years ago
Brian Coca 7067bb32b8 make all conditionals lists
this brings them to equivalence with when:
fixes #13905
10 years ago
Brian Coca e762095497 better task parsing errors
fixes #14790
10 years ago
Brian Coca 7ba790bbaf don't tempalte register 10 years ago
夏恺(Xia Kai) d033c40e80 Make task repr really work for meta tasks.
Signed-off-by: 夏恺(Xia Kai) <xiaket@xiaket@gmail.com>
10 years ago
Brian Coca 28cf4bc00b fix incorrect environment processing
it was assumed it could only be a dict or string (it starts out as a list)
also a 2nd assumption that bare vars only would appear in one of the dict keys.

removed deprecation warnings from here as they should be signaled in the bare conversion itself.
10 years ago
James Cammarata 07a9a54b0e Fix lookup of parent attribute when parent doesn't have the attr
Fixes #14100
10 years ago
James Cammarata d07d974ad8 Revert "Properly look for parent become attribute"
This reverts commit 1b46a422aa.
10 years ago
James Cammarata 1b46a422aa Properly look for parent become attribute
Corrects inheritence of the boolean value, which needs some special
consideration from other (string/int) values.

Fixes #13872
10 years ago
James Cammarata 1825b4a9c7 Fix any_errors_fatal incorrect implementation in 2.0
Also adds that flag to blocks.

Fixes #13744
10 years ago
James Cammarata 3ec0104128 Fixing bugs in conditional testing with until and some integration runner tweaks 10 years ago
Toshio Kuratomi 224d596336 Remove args from get_name() as we can't tell if any of the args are no_log 10 years ago
James Cammarata a3dcb910b8 Fixing bugs with {changed,failed}_when and until with registered vars
* Saving of the registered variable was occuring after the tests for
  changed/failed_when.
* Each of the above fields and until were being post_validated too early,
  so variables which were not defined at that time were causing task
  failures.

Fixes #13591
10 years ago
Brian Coca c64298de02 Revert "avoid persistent containers in attribute defaults"
This reverts commit 87969868d4.
found better way to do it
10 years ago
Brian Coca 87969868d4 avoid persistent containers in attribute defaults
moved from the field attribute declaration and created a placeholder
which then is resolved in the field attribute class.

this is to avoid unwanted persistent of the defaults across objects which introduces
stealth bugs when multiple objects of the same kind are used in succession while
not overriding the default values.
10 years ago
James Cammarata 398f6bbb89 Fix typo from 5ae850c 10 years ago
James Cammarata de690445bc Make fact delegating configurable, defaulting to 1.x behavior 10 years ago
Nils Steinger a1f6d17e37 More meaningful string representation for meta tasks (like 'noop' and 'flush_handlers') 10 years ago
James Cammarata 91500f8f5f Fix include param precedence in variable manager 10 years ago
Toshio Kuratomi 62979efa14 Finish up plugin porting to global display
Also remove display = display which does nothing
10 years ago
Toshio Kuratomi 7ecfa072da Move the rest of the playbook code to use global display 10 years ago
James Cammarata 76ae577519 Ensure environment is inherited properly (task->block/include->play) 10 years ago
James Cammarata 299054852a Allow tags to be specified in included file params
Fixes #12940
10 years ago
James Cammarata 3fc2209ca0 Fixing retry/until logic and default value for retries
Fixes #12928
Fixes #12929
10 years ago
Brian Coca d861e7dd5d moved several directives so they are not settable at play, block, role and task levels 10 years ago
James Cammarata 2b3c5aa41e Support cmd param in Tasks by assigning it to _raw_params
Fixes #12856
10 years ago
James Cammarata e5b6d802bf Removing some cruft related to _local_action value on Task, which was removed
Fixes #12819
10 years ago
Toshio Kuratomi baa309309d Bundle a new version of python-six for compatibility along with some code to make it easy for distributions to override the bunndled copy if they have a new enough version. 10 years ago
Marius Gedminas f03da5be42 Python 3: there's no iteritems() 10 years ago
Brian Coca abf2e13955 Revert "Track local_action internally to prevent it from being overridden"
This reverts commit 49ca0eb797.
10 years ago
Brian Coca 101c8785ec removed changes to make local action equate connection=local and brought it back to equate delegate_to=localhost 10 years ago
Juraci 254d6be520 Adding get_path method to Task class 10 years ago
Marius Gedminas 5edd6d9be4 Python 3: there's no basestring
Fixes another failing test.

(I don't want to do a global search/replace for 'basestring' because I
want to have unit tests covering each occurrence.  When I run out of
existing failing tests, I'll try to write new ones.)
10 years ago
James Cammarata 6dd38c2a10 Fix parent attribute lookup to be default
Fixes #12526
10 years ago
James Cammarata 49ca0eb797 Track local_action internally to prevent it from being overridden
Fixes #12053
10 years ago
James Cammarata ee7905c7e1 Compare include params against deprecated param names too
Fixes #12282
10 years ago
Marius Gedminas 823677b490 Replace .iteritems() with six.iteritems()
Replace .iteritems() with six.iteritems() everywhere except in
module_utils (because there's no 'six' on the remote host).  And except
in lib/ansible/galaxy/data/metadata_template.j2, because I'm not sure
six is available there.
10 years ago
James Cammarata 50448d68e1 Implement max_fail_percentage and any_errors_fatal support
Fixes #11997
10 years ago
James Cammarata 601a1cc6d9 Multiple fixes for include statements and blocks in general
Fixes #11981
Fixes #11995
Fixes #12039
Fixes #12077
10 years ago
Brian Coca ae91cdfc98 fixed environment inheritance 10 years ago
Brian Coca 7a4a156d91 changed local_action to alias to connection=local vs delegate_to=localhost
fixes #11998, but still leaves issue of delegate_to: localhost not working
10 years ago
James Cammarata 4714cbeec8 Override post validation of environment to allow bare variables
Also prints a deprecated warning if a bare variable is detected, so
that we can remove this in a future version.

Fixes #11912
10 years ago
James Cammarata ac66e4001c Fix for variable precedence with tasks/includes
Fixes #11881
10 years ago
James Cammarata e7d0c9f820 Re-add vars to Base and standardize var processing
Fixes #11779
10 years ago
James Cammarata 5eb092b331 Handle top-level vars for include tasks to match v1 syntax
The "streamlined" syntax will be deprecated at some point in the future.

Fixes #11882
10 years ago
James Cammarata c3ce140dd2 Exclude loop_args from post_validation for tasks
This field is templated specially during the TaskExecutor's loop
calculation, so there's no need to post validate it again.

Fixes #11481
11 years ago
James Cammarata efcad3aa6d Re-allow vars on tasks, specifically for includes 11 years ago
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
11 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