Commit Graph

75 Commits (c7c8481181e96dab508e11917551551f83c5b677)

Author SHA1 Message Date
Brian Coca 30c6a77045 moved any_errors_fatal to base (#21585) 2017-03-02 10:28:20 -05:00
James Cammarata 3d65482927 Stash post-validated fields of the task in the TaskResult
This allows us to have a snapshot of the fields, which we can restore
on the pre-fork side so as to avoid having to re-template fields.
2017-02-21 14:35:13 -06:00
James Cammarata 4cbe610263 Use a custom id generator over uuid4
>>> timeit.timeit("uuid.uuid4()", setup="import uuid")
9.518647909164429
>>> timeit.timeit("get_unique_id()", setup="from __main__ import get_unique_id")
0.40436601638793945

This will mainly be beneficial when a very large inventory is being
used, however it may also help with some very large playbooks.
2017-02-10 14:38:38 -06:00
Brian Coca ca1514cf2a unified boolean function
optimized boolean function
fixes #17815
2016-11-29 12:34:30 -05:00
James Cammarata 4859e0a419 Look for _get_parent_attribute method in both src and dst dict
When determining which getter style to use for the object in question,
the BaseMeta class should look at both dict's to try and locate the method.

Fixes #18522
2016-11-23 12:51:38 -06:00
James Cammarata 435ca620b2 Add option to prepend inherited attributes when extending values
Fixes #18483
2016-11-14 16:33:01 -06:00
James Cammarata 5b87951d6c Don't copy the parent block of TaskIncludes when loading statically
When loading an include statically, we previously were simply doing a
copy() of the TaskInclude object, which recurses up the parents creating
a new lineage of objects. This caused problems when used inside load_list_of_blocks
as the new parent Block of the new TaskInclude was not actually in the list
of blocks being operated on. In most circumstances, this did not cause a
problem as the new parent block was a proper copy, however when used in
combination with PlaybookInclude (which copies conditionals to the list of
blocks loaded) this untracked parent was not being properly updated, leading
to tasks being run improperly.

Fixes #18206
2016-11-11 08:09:43 -06:00
James Cammarata 4794b5da45 Merge class dict with parent dict when creating meta attributes
In some situations, where the Base class defines an Attribute, the
BaseMeta class doesn't properly see the _get_parent_attribute or
_get_attr_<whatever> methods because of multiple layers of subclasses
(ie. Handler, which subclasses Task). This addresses that by merging
the __dict__ of the parent with the current classes __dict__ meaning
all future iterations see available special methods.

Fixes #18378
2016-11-07 21:30:01 -06:00
Toshio Kuratomi 6a3893c518 Remove direct calls to print and cleanup imports
All display of information should go through display instead of through print.
2016-11-07 17:12:36 -05:00
Toshio Kuratomi 4ed88512e4 Move uses of to_bytes, to_text, to_native to use the module_utils version (#17423)
We couldn't copy to_unicode, to_bytes, to_str into module_utils because
of licensing.  So once created it we had two sets of functions that did
the same things but had different implementations.  To remedy that, this
change removes the ansible.utils.unicode versions of those functions.
2016-09-06 22:54:17 -07:00
Brian Coca ff34f5548d Dynamic role include (#17401)
* dynamic role_include

* more fixes for dynamic include roles

* set play yfrom iterator when dynamic

* changes from jimi-c

* avoid modules that break ad hoc

TODO: should really be a config
2016-09-05 20:07:58 -04:00
James Cammarata 9ecec6c28e Don't do parent stuff during serialize if squashed or finalized 2016-08-31 13:33:01 -05:00
James Cammarata cddf1cf98e Some further cleanup in the meta branch
* adds squashing to objects, which allows them to be squashed down
  to a final "view" before post_validate to avoid expensive evaluations
  of parent attributes
2016-08-31 13:33:01 -05:00
James Cammarata 96e2be9bf8 Selectively assign the getter for better performance
Introduces the `inherit` param for FieldAttributes, which is now used
in BaseMeta when constructing the getter property to enhance performance
by reducing the amount of work the getter generally has to do.
2016-08-31 13:33:01 -05:00
James Cammarata 3a51587220 Meta meta meta 2016-08-31 13:33:01 -05:00
James Cammarata f4237b2151 Rework the way params are assigned to TaskIncludes when they're dynamic
Copying the TaskInclude task (which is the parent) before loading the blocks
makes the code much more simple and clean, and fixes a bug introduced during
the performance improvement changes (and specifically the change which moved
things to a single-parent model).

Fixes #17064
2016-08-16 15:45:24 -05:00
James Cammarata 57fca2dde2 Validate new blocks during copy
It is possible that a block is copied prior to validation, in which case
some fields (like when) which should be something other than a string might
not be. Using validate() in copy() is relatively harmless and ensures the
blocks are in the proper structure.

This also cleans up some of the finalized logic from an earlier commit and
adds similar logic for validated.

Fixes #17018
2016-08-10 08:27:59 -05:00
James Cammarata 7503875ed7 Mark playbook objects as finalized after post_validate
After post_validate() is called on an object, there should be no
need to continue looking up at parent attributes. This patch adds a
new flag (_finalized) which is set to True at the end of post_validate,
and getattr will not look beyond its own attributes from that point on.
2016-08-09 08:57:21 -05:00
James Cammarata 06d4f4ad0e Move tasks/blocks to a single parent model 2016-08-08 15:58:46 -05:00
James Cammarata d2b3b2c03e Performance improvements 2016-08-08 15:58:46 -05:00
Robin Roth 2b28beb1d7 add check_mode option for tasks (#16056)
* add check_mode option for tasks

includes example testcases for the template module

* extend check_mode option

* replace always_run, see also proposal rename_always_run
* rename always_run where used and add deprecation warning
* add some documentation

* have check_mode overwrite always_run

* use unique template name to prevent conflicts

test_check_mode was right before, but failed due to using the same filename as other roles

* still mention always_run in the docs

* set deprecation of always_run to version 2.4

* fix rst style

* expand documentation on per-task check mode
2016-07-22 20:40:14 -04:00
James Cammarata 04fca42b62 Fixing issues with getattr caused by 5a3493b 2016-06-24 15:43:03 -05:00
nitzmahone ac04ffb9b1 apply @zazard's fix to parent attribute lookup 2016-06-23 14:11:07 -07:00
James Cammarata c24c0f5f6b Properly wrap objects using json default encoder
Our custom encoder for the to_json filter was simply returning the
object if it was not a HostVars object, leading in some cases to a
TypeError when the data contained an undefined variable. This lead
to an odd error message being propagated up, so we now properly catch
this as an undefined variable error.

Fixes #15610
2016-06-23 09:19:32 -05:00
Toshio Kuratomi 5a3493be5f Port urls.py to python3 and other byte vs text fixes (#16124)
* Port urls.py to python3

Fixes (largely normalizing byte vs text strings) for python3

* Rework what we do with attributes that aren't set already.

* Comments
2016-06-04 16:19:57 -07:00
Toshio Kuratomi 09605ce806 Fix facts for the FieldAttribute list change in 30a38f9 2016-04-22 16:31:53 -07:00
James Cammarata 30a38f94ce Create a special class of list FieldAttribute for splitting on commas
Which we're use on a case-by-case basis if we find people were actually
using comma-separated strings for list values outside of hosts. Support
for doing so is now deprecated and users should instead use the full
YAML syntax for lists of values.

Fixes #15291
2016-04-22 14:21:14 -04:00
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
2016-04-19 01:42:40 -04:00
Toshio Kuratomi d665911bab Allow FieldAttribute lists and sets to be set from a comma separated string 2016-03-14 14:53:29 -07:00
James Cammarata 299d93f6e9 Updating unit tests for PlayIterator
This knowingly introduces a broken test, planning to fix that later.
2016-03-07 13:03:06 -05:00
John Barker 8b4ebd8e4a Make it easier to read error message 2016-03-07 12:49:41 +00:00
Thomas Quinot 2eb22d5536 Fix minor typo in comment 2016-01-10 10:27:50 +01:00
Brian Coca b92cb93539 unconditionally set vars on init to avoid issues with var precedence 2015-12-01 21:24:46 -08:00
Brian Coca a6f6a80caa avoid inheritance issues with default=dict declaration at class level
this should avoid the issue of subsequent plays not prompting for a var
prompted for in a previous play.
2015-12-01 08:18:31 -08:00
Toshio Kuratomi 1b743436b9 Do not double transform to unicode 2015-11-25 07:48:52 -08:00
Charles Paul 1e5a205389 fixing errors with utf-8 values
removing utf-8 stanza

changing cast to binary_type instead

using to_unicode
2015-11-25 11:47:25 +09:00
Toshio Kuratomi 7ecfa072da Move the rest of the playbook code to use global display 2015-11-11 10:44:22 -08:00
Toshio Kuratomi c7b69127ec Remove dead code 2015-11-11 08:12:21 -08:00
James Cammarata e36b4e2a13 Merge pull request #13072 from Yannig/devel_cache_optimization
Cache optimization
2015-11-09 14:54:06 -05:00
James Cammarata 76ae577519 Ensure environment is inherited properly (task->block/include->play) 2015-11-09 14:51:07 -05:00
Yannig Perré 12a6fb9633 Small speed improvement with huge inventory (100+ hosts). 2015-11-07 19:32:10 +01:00
Toshio Kuratomi 4203850d1a Break apart a looped dependency to show a warning when parsing playbooks
Display a warning when a dict key is overwritten by pyyaml
Fixes #12888
2015-10-27 12:39:42 -07:00
James Cammarata 1dc23ea779 Merge pull request #12866 from bcoca/more_inheritence
More inheritence
2015-10-27 14:46:42 -04:00
James Cammarata 677a2f95e5 Make sure Base attributes are copied cleanly
Fixes #12882
2015-10-26 12:09:58 -04:00
James Cammarata 86de1429e5 Cleaning up FIXMEs 2015-10-22 16:03:50 -04:00
Brian Coca d861e7dd5d moved several directives so they are not settable at play, block, role and task levels 2015-10-22 07:51:22 -04:00
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. 2015-10-16 08:21:28 -07:00
James Cammarata 63e288354e Fix bug in way omitted values were set 2015-10-12 09:00:27 -04:00
James Cammarata 6dd38c2a10 Fix parent attribute lookup to be default
Fixes #12526
2015-09-26 11:28:29 -04:00
James Cammarata c9a004227e Improve error catching from malformed playbook data
Fixes #12478
2015-09-23 08:56:36 -04:00