summaryrefslogtreecommitdiff
path: root/lib/ansible/playbook/role/__init__.py
Commit message (Collapse)AuthorAgeFilesLines
* remove default from delegate_facts to inherit (#45492) (#51553)Brian Coca2019-02-041-1/+1
| | | | | | | | | | | | | | | | | | * remove default from delegate_facts to inherit (#45492) * remove default from delegate_facts to inherit fixes #45456 * test delegate_facts * added note about inheritance and defaults * yamllint (cherry picked from commit 8743e6ae2ee7aa3ae94038554110a9255f5d8fd8) * added changelog
* Prevent duplicate role insertion into roles: (#50552)Brian Coca2019-01-181-0/+3
| | | | | | | | | | | | | | | * Corner case in which import_role would add another instance of a role with the same signature into roles: when it already existed there. roles: - name: a tasks: - import_role: name=a would execute role 'a' 3 times instead of the intended 2 (x2 in roles: phase +1 in tasks:) * added tests (cherry picked from commit eca7c3c8c763db0da4bb56c17d17f0a5be0f56d8)
* Fix multiple var files combining (followup to #36357)Andrey Laguta2018-07-201-1/+1
|
* Add feature to expose vars/defaults with include/import_role (#41330)Matt Martz2018-07-151-4/+16
| | | | | | | | | | | | | | | | | | * First pass at making 'private' work on include_role, imports are always public * Prevent dupe task execution and overwriting handlers * New functionality will use public instead of deprecated private * Add tests for public exposure * Validate vars before import/include to ensure they don't expose too early * Add porting guide docs about public argument and change to import_role * Add additional docs about public and vars exposure to module docs * Insert role handlers at parse time, exposing them globally
* Load role vars and defaults before parsing tasks (#40982)Matt Martz2018-06-181-13/+13
| | | | | | | | | | | | * Load role vars and defaults before parsing tasks. Fixes #40163 * Add porting guide note * Wording clarifications * typo * grammar fixes
* Attempt 4: Prevent reparenting a block with itself (#38747)Matt Martz2018-04-161-3/+1
| | | | | | | | | | | | * More concisely reparent, ensuring we don't go too shallow or too deep in this process. Fixes #38357 * More explicit reparenting, with a short circuit for a common case * We need new_block to have a parent, otherwise we lose context with this approach * Remove duplicate parent assignment * Change callers of Block.copy to not use exclude_parent=True, when including the parent, exclude tasks
* Allow loading dirs from role defaults/vars (#36357)Andrew Gaffney2018-04-101-36/+24
| | | | | | | | | | This commit moves code to look for vars files/dirs to a common place and uses it for loading role defaults/vars. This allows things such as 'defaults/main' or 'vars/main' being a directory in a role, allowing splitting of defaults/vars into multiple files. This commit also fixes the role loading unit tests for py3 when bytestrings are used for paths instead of utf8 strings. This fixes #14248 and #11639.
* Remove uses of assert in production code (#32079)Matt Martz2017-11-131-2/+3
| | | | | | | | | | | | | | | | * Remove uses of assert in production code * Fix assertion * Add code smell test for assertions, currently limited to lib/ansible * Fix assertion * Add docs for no-assert * Remove new assert from enos * Fix assert in module_utils.connection
* Fix dangerous default args. (#29839)Matt Clay2017-09-121-4/+12
|
* Ansible Config part2 (#27448)Brian Coca2017-08-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Ansible Config part2 - made dump_me nicer, added note this is not prod - moved internal key removal function to vars - carry tracebacks in errors we can now show tracebacks for plugins on vvv - show inventory plugin tracebacks on vvv - minor fixes to cg groups plugin - draft config from plugin docs - made search path warning 'saner' (top level dirs only) - correctly display config entries and others - removed unneeded code - commented out some conn plugin specific from base.yml - also deprecated sudo/su - updated ssh conn docs - shared get option method for connection plugins - note about needing eval for defaults - tailored yaml ext - updated strategy entry - for connection pliugins, options load on plugin load - allow for long types in definitions - better display in ansible-doc - cleaned up/updated source docs and base.yml - added many descriptions - deprecated include toggles as include is - draft backwards compat get_config - fixes to ansible-config, added --only-changed - some code reoorg - small license headers - show default in doc type - pushed module utils details to 5vs - work w/o config file - PEPE ATE! - moved loader to it's own file - fixed rhn_register test - fixed boto requirement in make tests - I ate Pepe - fixed dynamic eval of defaults - better doc code skip ipaddr filter tests when missing netaddr removed devnull string from config better becoem resolution * killed extra space with extreeme prejudice cause its an affront against all that is holy that 2 spaces touch each other! shippable timing out on some images, but merging as it passes most
* Try to show original exception info for yaml (and other) errors (#24468)Adrian Likins2017-06-091-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * show original exception for yaml (and other) errors In places where we need to catch a yaml error and raise an AnsibleError, add the orig yaml exc to the AnsibleError via the orig_exc arg. When the AnsibleError is displayed it will now include the AnsibleError (AnsibleParserError for example) and the type and message from the original yaml exception. This provides more detail to the error messages related to yaml errors. This also improves errors from dataloader (for example, previously if a wrong password was used for a vault encrypted yaml file, the error was very vague and suggested yaml errors, but now the message includes the original exception from vault indicating the password was incorrect or missing). Add a text note to playbook helper asserts. For playbook syntax/layout errors that aren't yaml errors, but errors indicating invalid data structures for a playbook/task/role/block, we now include some info about where the assert was and why it was raised. In places we raise an AnsibleParserError in an except clause, pass the original exception to AnsibleParserError via orig_exc arg. Make assorted error messages a little more specific (like the playbook helper load methods) * Revert "Include the original YAML error in syntax error messages" This reverts commit 781bb44b029becef60af9c9ce765129c7c9c7287.
* Collated PEP8 fixes (#25293)Dag Wieers2017-06-021-38/+37
| | | - Make PEP8 compliant
* Update module_utils.six to latest (#22855)Toshio Kuratomi2017-03-231-1/+1
| | | | | | | | * Update module_utils.six to latest We've been held back on the version of six we could use on the module side to 1.4.x because of python-2.4 compatibility. Now that our minimum is Python-2.6, we can update to the latest version of six in module_utils and get rid of the second copy in lib/ansible/compat.
* E501 fixes (#22879)Matt Martz2017-03-221-2/+4
|
* Reworking the way end of role detection is doneJames Cammarata2017-01-181-1/+3
| | | | | | | | | | Rather than trying to enumerate tasks or track an ever changing cur_role flag in PlayIterator, this change simply sets a flag on the last block in the list of blocks returned by Role.compile(). The PlayIterator then checks for that flag when the cur_block number is incremented, and marks the role as complete if the given host had any tasks run in that role. Fixes #20224
* make hash_params more robust in the face of many corner cases (#18701)Toshio Kuratomi2016-12-051-19/+48
| | | | | | | | | | | | | | * make hash_params more robust in the face of many corner cases Fixes #18680 Alternative fix to #18681 * add test case for role.hash_params * Add role.hash_params test for more types A set, a generator/iterable, and a Container that is not Iterable.
* improved error msgBrian Coca2016-10-201-1/+1
|
* role now fails if specified file not foundBrian Coca2016-10-201-0/+2
| | | | fixes https://github.com/ansible/ansible-modules-core/issues/5166
* Meta meta metaJames Cammarata2016-08-311-1/+1
|
* allow include_role to specify vars/defaults filesBrian Coca2016-08-261-4/+4
|
* include_role (role revamp implementation) (#17232)Brian Coca2016-08-261-11/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * attempt #11 to role_include * fixes from jimi-c * do not override load_data, move all to load * removed debugging * implemented tasks_from parameter, must break cache * fixed issue with cache and tasks_from * make resolution of from_tasks prioritize literal * avoid role dependency dedupe when include_role * fixed role deps and handlers are now loaded * simplified code, enabled k=v parsing used example from jimi-c * load role defaults for task when include_role * fixed issue with from_Tasks overriding all subdirs * corrected priority order of main candidates * made tasks_from a more generic interface to roles * fix block inheritance and handler order * allow vars: clause into included role * pull vars already processed vs from raw data * fix from jimi-c blocks i broke * added back append for dynamic includes * only allow for basename in from parameter * fix for docs when no default * fixed notes * added include_role to changelog
* Move tasks/blocks to a single parent modelJames Cammarata2016-08-081-1/+3
|
* Merge pull request #16555 from matsu-chara/fix-error-msg-default-to-defaultsMatt Davis2016-07-071-1/+1
|\ | | | | fix default/main.yml to defaults/main.yml
| * fix default/main.yml to defaults/main.ymlmatsu-chara2016-07-021-1/+1
| |
* | Fix the way handlers are compiled and found/notifiedJames Cammarata2016-07-061-3/+15
|/ | | | | | | | | | | | * Instead of rebuilding the handler list all over the place, we now compile the handlers at the point the play is post-validated so that the view of the play in the PlayIterator contains the definitive list * Assign the dep_chain to the handlers as they're compiling, just as we do for regular tasks * Clean up the logic used to find a given handler, which is greatly simplified by the above changes Fixes #15418
* Remove unnecessary role initialization and lookup stuffJames Cammarata2016-06-231-10/+0
| | | | | | | | | | | * Remove unnecessary copying of values from parents to role deps, as this can cause problems when roles have multiple parents (or the same parents with different params speficied through deps) * Since we're already checking the dep chain in the block for role things (which every task in a role should have), it is not necessary to check the role directly in case it improperly grabs something Fixes #14438
* Add options to make includes 'static'James Cammarata2016-03-241-4/+4
| | | | | | * Can be configured in the ansible.cfg for tasks/handlers individually * If an included filename contains no vars or loops, it will be expanded in-place as if it were marked as static
* Make default var lookup for tasks follow the dep chainJames Cammarata2016-03-241-1/+4
| | | | Related to #14296 (@jjshoe's follow-up example on that issue)
* Fixing role param precedence issuesJames Cammarata2016-03-201-8/+8
| | | | | | | | | | | | | * Make role param resolution follow the role dependency chain, rather than using all roles within the play * Also move params to be merged in after role vars in general, to match our variable precedence rules * Changes to the way var lookup is done in role helper methods for get_vars(), get_inherited_vars(), and get_role_params() to make the above possible without trampling on previously merged vars Fixes #14472 Fixes #14475
* Fixing bugs related to nested blocks inside rolesJames Cammarata2016-02-121-4/+5
| | | | | | | | | | | | * Make sure dep chains are checked recursively for nested blocks * Fixing iterator is_failed() check to make sure we're not in a rescue block before returning True * Use is_failed() to test whether a host should be added to the TQM failed_hosts list * Use is_failed() when compiling the list of hosts left to iterate over in both the linear and free strategies Fixes #14222
* Fixing role dependency chain creationJames Cammarata2016-01-221-7/+9
| | | | | | | | | | The dep chain for roles created during the compile step had bugs, in which the dep chain was overwriten and the original tasks in the role were not assigned a dep chain. This lead to problems in determining whether roles had already run when in a "diamond" structure, and in some cases roles were not correctly getting variables from parents. Fixes #14046
* Fix role hashing failure/traceback when params contain listsJames Cammarata2016-01-191-1/+4
| | | | Fixes #13857
* Merge role params into variables separately from other variablesYannig Perré2015-12-211-0/+6
| | | | Fixes #13617
* narrow down exception catching in block buildsBrian Coca2015-12-111-2/+2
| | | | this was obscuring other errors and should have always been narrow scope
* Fix typo from 5ae850cJames Cammarata2015-12-081-1/+1
|
* Make fact delegating configurable, defaulting to 1.x behaviorJames Cammarata2015-12-081-0/+1
|
* Catch additional assertion errors for load_list_of_blocksMatt Martz2015-12-021-2/+8
|
* Cleaning up FIXMEsJames Cammarata2015-10-221-6/+4
|
* Bundle a new version of python-six for compatibility along with some code to ↵six-compatToshio Kuratomi2015-10-161-1/+1
| | | | make it easy for distributions to override the bunndled copy if they have a new enough version.
* galaxy updatesBrian Coca2015-10-051-5/+0
| | | | | | | | | | | | | better error reporting on fetching errors use scm if it exists over src unified functions in requirements simplified logic added verbose to tests cleanup code refs, unused options and dead code moved get_opt to base class fixes #11920 fixes #12612 fixes #10454
* Allow delegate_to on a role againJames Cammarata2015-09-291-0/+2
| | | | Fixes #12560
* Properly template role dependency namesJames Cammarata2015-09-291-1/+1
| | | | Fixes #12505
* Restrict role param vars to tasks within that roleJames Cammarata2015-09-221-6/+8
| | | | Fixes #12460
* corrected all missing paths changesBrian Coca2015-09-151-1/+1
|
* Replace .iteritems() with six.iteritems()Marius Gedminas2015-09-031-2/+2
| | | | | | | 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.
* Avoid types.NoneTypeMarius Gedminas2015-08-271-7/+6
| | | | | | | types.NoneType was removed in Python 3. None is a singleton in Python, so 'x is None' is equivalent to 'isinstance(x, NoneType)'.
* Don't mix tabs and spacesMarius Gedminas2015-08-271-1/+1
| | | | It's not allowed in Python 3 and merely a bad idea in Python 2.
* Track role execution per-host, not overall in the roleJames Cammarata2015-08-111-8/+8
| | | | | Fixes #11863 Fixes #11878
* Use templar all the way downJames Cammarata2015-08-041-3/+1
| | | | | | | | Fixes bugs related to creating Templar() objects on the fly, where the shared loader objects (serialized to TaskExecutor) aren't used so information loaded into plugin loaders after forking is lost. Fixes #11815
* Remove outdated FIXME; ROLE_CACHE is already implemented belowAbhijit Menon-Sen2015-08-011-1/+0
|