summaryrefslogtreecommitdiff
path: root/lib/ansible/inventory
Commit message (Collapse)AuthorAgeFilesLines
* Use ansible.module_utils.common.text.converters (#80704)Matt Clay2023-05-032-2/+2
| | | Replace use of old `ansible.module_utils._text` and add a unit test to maintain backwards compatibility.
* ansible-test - Update sanity test requirements. (#78528)Matt Clay2022-08-112-2/+2
|
* preserve add_host/group_by on refresh (#77944)Brian Coca2022-06-061-1/+103
| | | | | * preserve add_host/group_by on meta: refresh_inventory Co-authored-by: Jordan Borean <jborean93@gmail.com>
* Hide "[WARNING]: No inventory was parsed" message (#65499)Jon "The Nice Guy" Spriggs2022-04-061-1/+1
| | | * Add config option INVENTORY_UNPARSED_WARNING to hide the warning "No inventory was parsed, only implicit localhost is available"
* inventory manager respect --flush-cache (#77083)Brian Coca2022-03-171-3/+2
|
* Remove collections compat from controller code.Matt Clay2022-03-082-2/+3
|
* avoid polluting vars with incorrect settings (#76590)Brian Coca2022-02-071-1/+7
| | | | | | | | | | | | | avoid polluting vars with incorrect settings simplify variables and templars - variables, original, only updated with final results, reset are copies of this - tempvars used for preliminary templating - cvars used for connection/shell/become plugins, delegation aware - vars_copy ignore tempvars updates and use connection plugin to get finalized version per loop item/delegation, also used to store temp results till we are ready to update 'variables' - fine tune nolog just cause we are here - also fix inventory_hostname_short for IP addresses
* Remove more whitelist and blacklist occurances (docs only). (#76845)Felix Fontein2022-01-261-1/+1
|
* Start of moving away from six (#75863)Martin Krizek2021-10-211-2/+2
| | | ci_complete
* inventory: misc typo fixes (#73695)Abhijeet Kasurde2021-02-231-2/+2
| | | | | * Misc typo fixes Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* [InventoryManager] Fix two unhandled exceptions (#73667)Rick Elrod2021-02-221-1/+3
| | | | | | | | | | | | | | | | | | | Change: - Fix regression: unhandled exception when given inventory directory is empty or contains empty subdirectories. - Fix unhandled exception when limit file is actually a directory instead of a file. - Fix inventory tests which previously could never fail due to missing `set -e`. Fixed up tests that failed after `set -e` was added. Added several tests. Test Plan: - New tests - Fixed existing tests which previously could never fail Tickets: - Fixes #73658 Signed-off-by: Rick Elrod <rick@elrod.me>
* allow constructed to use vars plugin (#73418)Brian Coca2021-02-122-1/+6
| | | | | | Allow constructed to optionally use vars plugin data * mostly for those looking to leverage group_vars/ and host_vars/ * limited to already processed sources
* fix inventory source parse error handling (#73160)Brian Coca2021-01-181-8/+13
| | | | | fixes #51025 added test cases
* Pass the top level dictionaries to combine_vars (#72979)Sloane Hertel2020-12-162-2/+2
| | | | | * Pass the top level dictionaries to combine_vars combine_vars uses dict.update() to replace keys
* don't set warn = True, it will be overwritten in the next line (#71682)Evgeni Golov2020-09-121-1/+0
|
* Use InventoryManager for inventory_hostnames lookup (#71573)Matt Martz2020-09-021-2/+3
| | | | | | | | | | | * Use InventoryManager for inventory_hostnames lookup. Fixes #17268 * Add test for using patterns * s/it's/its/ * Allow bypassing parse_sources in InventoryManager * Remove unneeded method call
* return changed for group_by (#32057)Brian Coca2020-06-033-7/+19
| | | | | * return changed for group_by * added tests and fixed 'early registeration'
* Remove deprecation for TRANSFORM_INVALID_GROUP_CHARS (#66650)Martin Krizek2020-05-131-6/+0
| | | Fixes #61889
* Remove some no-op code from InventoryManagerRick Elrod2020-05-072-4/+5
| | | | | | | | | | | | Change: - Remove some no-op code - Split up a somewhat complex line into two lines - Nuke an incorrect comment Test Plan: CI Signed-off-by: Rick Elrod <rick@elrod.me>
* Remove left hand side slicingToshio Kuratomi2020-05-061-6/+6
| | | | | | | | | | | | | | | | Left hand side slicing is confusing and slower but maybe more memory efficient in some circumstances. There is one case where it adds to code safety: when it's used to substitute a different list in place of a slice of the original list and the original list could have been bound to a different variable in some other code. (The most likely case of this is when it's a global variable and some other code might import that variable name). Because of the confusion factor we think it should only be used for the safety case or where it's been benchmarked and shown to have some sort of documentatble improvement. At the moment, only one piece of code falls into those categories so this PR removes all the other instances of left hand side slicing.
* inventory: Fail on non-existing limit file (#59758)Abhijeet Kasurde2019-12-121-3/+8
| | | | | | Ansible now fails with error message when user provides non-existing limit file. Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Support vars plugins in collections (#61078)Sloane Hertel2019-11-041-0/+7
| | | | | | | | | | | | | | | | | | | | | | | * Move var plugins handling to a separate file * Allow var plugins to require whitelisting * Add global configuration ('demand', 'start') for users to control when they execute * Add 'stage' configuration ('all', 'task', 'inventory') for users to control on a per-plugin basis when they execute * Update ansible-inventory and InventoryManager to the global and stage configuration * Update host_group_vars to use stage configuration and whitelisting * Add documentation for using new options and to the developer's guide * Add integration tests to exercise whitelisting and the new configuration options, using vars plugins in collections, and maintain backward compatibility * Changelog Co-Authored-By: Brian Coca <brian.coca+git@gmail.com> Co-Authored-By: Sandra McCann <samccann@redhat.com>
* Account for empty strings when splitting the host pattern (#62442)Sam Doran2019-09-201-1/+1
| | | | | | | | Improve tests - add more unit test cases - add specific integration test with more cases Testing shows no major downside to calling .strip() twice in a comprehension vs. using a regular for loop and only calling .strip() once. Going with the comprehension for ease of maintenance and because comprehensions are optimized in CPython.
* inventory: Handle IndexError while parsing limit file (#59776)Abhijeet Kasurde2019-07-301-1/+4
| | | | | | | Handle IndexError exception raised while parsing the limit file. Fixes: #59695 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Perfy McPerferton (#58400)Matt Martz2019-07-221-40/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * InventoryManager start of perf improvements * 0 not 1 * More startswith to [0] improvements * Remove unused var * The hash doesn't need to be a string, start as a list, make it into a tuple * set actually appears faster than frozenset, and these don't need to be frozen * Cache hosts lists, to avoid extra get_hosts calls, pass to get_vars too * negligible perf improvement, it could help with memory later * Try the fast way, fallback to the safe way * Revert to previous logic, linting fix * Extend pre-caching to free * Address test failures * Hosts are strings * Fix unit test * host is a string * update test assumption * drop SharedPluginLoaderObj, pre-create a set, instead of 2 comparisons in the list comprehension * Dedupe code * Change to _hosts and _hosts_all in get_vars * Add backwards compat for strategies that don't do set host caches * Add deprecation message to SharedPluginLoaderObj * Remove unused SharedPluginLoaderObj import * Update docs/comments * Remove debugging * Indicate what patterh_hash is * That won't work * Re-fix tests * Update _set_hosts_cache to accept the play directly, use without refresh in get_hosts_remaining and get_failed_hosts for backwards compat * Rename variable to avoid confusion * On add_host only manipulate _hosts_cache_all * Add warning docs around _hosts and _hosts_all args
* Typo fixes (#59227)Abhijeet Kasurde2019-07-191-1/+1
| | | Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Stop ignoring merge hash behaviour in inventory (#58460)Brian Coca2019-07-172-3/+11
| | | | | | | | | | * stop ignoring merge hash behaviour in inventory fixes #58120 * added porting note Co-Authored-By: Alicia Cozine <879121+acozine@users.noreply.github.com>
* Perf improvement for Templar.is_template (#57489)Matt Martz2019-06-061-2/+2
| | | | * Faster is_template
* Correct grammar (#57385)Paul Gear2019-06-061-1/+1
| | | | "it's" == "it is" "its" == "belonging to it"
* group_chars: default change warning only when neededJames Cassell2019-06-041-2/+4
|
* The InventoryData class does not have a get_vars method and ↵Sloane Hertel2019-05-221-3/+0
| | | | InventoryManager's get_vars never appears to have been used (#56804)
* preserve same order as inventory manager when using host lookup (#55331)Sloane Hertel2019-04-181-2/+2
| | | | | | | | * preserve same order as inventory manager when using inventory_hostnames lookup add a test * move generic code
* Better test for cache method availability (#54740)Brian Coca2019-04-091-14/+12
| | | | | | | | | | | | * Better test for cache method availability fixes #54737 * try and ignore missing method * avoid plugin cross contamination * ammend clog
* Strip whitespace when reading limit file (#53564)Sebastian Meyer2019-03-181-1/+1
| | | Fix #17088
* Fine tune sanity (#53544)Brian Coca2019-03-111-4/+17
| | | | | | | | | * modify regex to use implicit charsets this should solve issues in py3 and unicode names * fix issue with subgroups in yaml inventory * clarify deprecation message * separated per name warning from deprecation * move noise to verbosity, simplify warnings * fix docs to reflect actual 'good' practice * change toggle to choice list to give users more options
* Fix inventory cache interface (#50446)Sloane Hertel2019-03-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * Replace InventoryFileCacheModule with a better developer-interface Use new interface for inventory plugins with backwards compatibility Auto-update the backing cache-plugin if the cache has changed after parsing the inventory plugin * Update CacheModules to use the config system and add a deprecation warning if they are being imported directly rather than using cache_loader * Fix foreman inventory caching * Add tests * Add integration test to check that fact caching works normally with cache plugins using ansible.constants and inventory caching provides a helpful error for non-compatible cache plugins * Add some developer documentation for inventory and cache plugins * Add user documentation for inventory caching * Add deprecation docs * Apply suggestions from docs review * Add changelog
* Add toggle to control invalid character substitution in group names (#52748)Brian Coca2019-03-062-10/+38
| | | | | | | | | | | | | | * make add_group return proper name * ensure central transform/check * added 'silent' option to avoid spamming current users those already using the plugins were used to the transformations, so no need to alert them * centralized valid var names * dont display dupes * comment on regex * added regex tests ini and script will now warn about deprecation * more complete errormsg
* support deterministic host ordering from group ancestors (#44067)Alan Rominger2019-02-201-14/+21
| | | Fixes #44065
* make missing pattern ansibleerror (#51397)Brian Coca2019-01-301-1/+1
| | | | ansibleoptionserror should be limited to cli options (technically --limit makes this a bit grey but hosts: should not trigger the same error)
* add toggle for host pattern mismatch behaviour (#51199)Brian Coca2019-01-251-1/+7
| | | | | | | | * add toggle for host pattern mismatch behaviour fixes #40030 * fix
* remove usless tb initiatorBrian Coca2019-01-221-8/+7
| | | | always pass proper tb
* Fix missing tracebacks in ansible-inventoryAlanCoding2019-01-221-0/+5
| | | | (cherry picked from commit b62693299b3d561c9a0a78c6c8e440f3c623b5d1)
* Minor typos (#50371)Abhijeet Kasurde2019-01-151-1/+1
| | | Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Fix reverse_inventory order to work on python3 (#49895)Matt Martz2018-12-171-3/+4
|
* Inventory plugins move auto before ini (#44428)Pilou2018-12-111-1/+1
| | | | | | | | | | | | | * inventory plugins: try auto before ini auto plugin should run before ini to avoid ini being able to parse some plugin configuration YAML files successfully. * Update comment comment was added by 2ffe3c42bb15263ad67dd36842712d9d3ec99070 but related code was later removed by 506e6a0b2d49a147e1c0c0b301c71163ea785d71.
* Merge pull request #49080 from bcoca/better_invp_skipBrian Coca2018-11-271-1/+1
| | | more precise pluing skip msg and now in higher verbosity level
* Add a Singleton metaclass, use it with Display (#48935)Matt Martz2018-11-202-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | * Add a Singleton class, use it with Display * update six import * Move remaining failes to display singleton * Fix rebase issues * Singleton improvements * Add code-smell for 'from __main__ import display'. ci_complete * s/self/cls/g * Add docs for no-main-display * Address linting issues * Add changelog fragment. ci_complete * Implement reentrant lock for class instantiation in Singleton * Add Display singleton porting guide
* inventory: fix hostname check (#48789)Martin Krizek2018-11-161-1/+1
|
* inventory now errors for invalid group/host names (#45499)Brian Coca2018-11-151-1/+5
| | | | | | | | | | | | | | | | | | * inventory now errors for invalid group/host names also made yaml inventory slightly smarte fixes #45493 * add some 'YAML protection' to ini plugin * better msg * avoid ranges as positive match * pepe * expand inherited instead of total override
* make inventory warnings a bit smarter (#46284)Brian Coca2018-11-071-1/+3
| | | | less annoying for common cases add comment for 'tricky' conditional