Commit Graph

512 Commits (97cc0cce7f53b704f8541530e42d5e515584cd95)

Author SHA1 Message Date
Brian Coca 12a8363fae
Error on empty group/host name (#42584)
* error on false host/group name
6 years ago
Brian Coca 937e710485
ensure 'text' source assumptions (#42522)
* ensure 'text' source assumptions
6 years ago
Matt Martz abb05c98f3 Make sure we are comparing bytes extensions in inventory plugins (#42475)
* Ensure we are comparing text paths with extensions. Fixes #42118

* Add changelog
6 years ago
Sloane Hertel 44e5886385 Fix setting required options for inventory plugins (#42049)
* Fix setting required options for inventory plugins

* call set_options for yaml and script plugin
6 years ago
Brian Coca 89f169127b added missing raise 6 years ago
Abhijit Menon-Sen 276358c885
Introduce inventory.any_unparsed_is_failed configuration setting (#41171)
In the process of building up the inventory by parsing each inventory
source with each available inventory plugin, there are three kinds of
possible errors (listed in order from earliest to latest):

1. One source could not be parsed by a particular plugin.
2. One source could not be parsed by any available plugin.
3. ALL sources could not be parsed by any available plugin.

The errors in (1) are a part of normal operation, e.g., the script
plugin is expected to fail to parse an ini-format source, and we will
ignore that error and try the next plugin. There is currently no way to
control this, and no known compelling use-case for a setting to control
it. This commit does not make any changes here.

We implement "any_unparsed_is_failed" to handle (2) above. If enabled,
this requires that every available source be parsed validly by at least
one plugin. In an inventory comprising a static hosts file and ec2.py,
this setting will cause a fatal error if ec2.py fails (a situation that
attracted only a warning earlier).

We clarify that the existing "unparsed_is_failed=true" setting causes a
fatal error only in (3) above, i.e., if NO inventory source could be
parsed. In other words, if there is ANY valid source in the inventory
(e.g., an ini-format static file), no combination of errors and the
setting will cause a fatal error.

If you want to execute your playbooks when your inventory is…

    (a) complete, use "any_unparsed_is_failed=true".
    (b) not empty, use "unparsed_is_failed=true".

The "unparsed_is_failed" setting should be renamed to
"all_unparsed_is_failed", but this commit does not do so.

Fixes #40512
Fixes #40996
6 years ago
Andrew Gaffney 1cf07028d4
Don't display host pattern warning for empty groups (fixes #35255) (#39927) 6 years ago
Brian Coca d9430b79f9
Ensure non ansilbe exceptions keep tracebacks (#37523) 7 years ago
Brian Coca 2e852fcd6d return empty host list when pattern is empty
fixes #37894
7 years ago
AlanCoding 153c9bd539 Reduce recursion within group methods
This offers an optimization that allows loading larger
inventories of various structure by improving the
scaling laws involved for adding hosts and groups.

The primary speed benefit is the elimination of duplicate
recusion from traversing converging paths.
7 years ago
Toshio Kuratomi e707e71ec5 Except in specific cases, we want to use text strings on the controller 7 years ago
Izuke e02c72d856 Fixes #32146 Fixes reconcile inventory to correctly remove hosts from ungrouped 7 years ago
Brian Coca ef40e5e3b2 protect against plugins using verify incorrectly
assume false on any errors
7 years ago
Brian Coca fdbd1297cf catch all cases of no inventory when asked to fail
fixes #36034
7 years ago
Brian Coca 8ba8d1a131 remove new tmp var for localhost
this was causing issues with keep remote files as the 'local cleanup' would trump the setting.
it will revert back to using the 'remote path' setti.ng for 'localhost' actions.

fixes #35724
7 years ago
Sloane Hertel 4a1cc661c4 add inventory caching & use in virtualbox inventory plugin (#34510)
* Inventory caching

* Add inventory caching for virtualbox

* Don't populate cache for virtualbox with stdout, use a dict of inventory instead

* Fix error creating the cache dir if it doesn't exist

* Keep cache default False and set to True in VariableManager __init__

* Check all groups before determining if a host is ungrouped.
7 years ago
Brian Coca bbd6b8bb42 Temporary (#31677)
* allow shells to have per host options, remote_tmp

added language to shell
removed module lang setting from general as  plugins have it now
use get to avoid bad powershell plugin
more resilient tmp discovery, fall back to `pwd`
add shell to docs
fixed options for when frags are only options
added shell set ops in t_e and fixed option frags
normalize tmp dir usag4e

- pass tmpdir/tmp/temp options as env var to commands, making it default for tempfile
- adjusted ansiballz tmpdir
- default local tempfile usage to the configured local tmp
- set env temp in action

add options to powershell
shift temporary to internal envvar/params
ensure tempdir is set if we pass var
ensure basic and url use expected tempdir
ensure localhost uses local tmp
give /var/tmp priority, less perms issues
more consistent tempfile mgmt for ansiballz
made async_dir configurable
better action handling, allow for finally rm tmp
fixed tmp issue and no more tempdir in ballz
hostvarize world readable and admin users
always set shell tempdir
added comment to discourage use of exception/flow control

* Mostly revert expand_user as it's not quite working.

This was an additional feature anyhow.

Kept the use of pwd as a fallback but moved it to a second ssh
connection.  This is not optimal but getting that to work in a single
ssh connection was part of the problem holding this up.

(cherry picked from commit 395b714120522f15e4c90a346f5e8e8d79213aca)

* fixed script and other action plugins

ensure tmpdir deletion
allow for connections that don't support new options (legacy, 3rd party)
fixed tests
7 years ago
Brian Coca 87c75b19dd
dont warn on not matching 'all' (#32806)
* dont warn on not matching 'all'

the implicit localhost warning shoudl be enough

* centralized no hosts handling

also extended info on implicit only
7 years ago
Brian Coca ad94a3a6a2 fix reconcile to ensure 'ungrouped'
also removed redundant 'hosts to all' as all groups already ensure that inheritance
7 years ago
Adam Miller 3abc2cc968 locahost -> localhost typo in inventory/data.py (#33790)
Signed-off-by: Adam Miller <maxamillion@fedoraproject.org>
7 years ago
Brian Coca e50f931cf3 restore hostpattern regex/glob behaviour
they are back to matching both groups and hosts when they are a glob/regex

fixes #32906
7 years ago
Matt Clay e45c763b64 Fix invalid string escape sequences. 7 years ago
Brian Coca 23b1dbacaf
Config continued (#31024)
* included inventory and callback in new config

allow inventory to be configurable
updated connection options settings
also updated winrm to work with new configs
removed now obsolete set_host_overrides
added notes for future bcoca, current one is just punting, it's future's problem
updated docs per feedback
added remove group/host methods to inv data
moved fact cache from data to constructed
cleaner/better options
fix when vars are added
extended ignore list to config dicts
updated paramiko connection docs
removed options from base that paramiko already handles
left the look option as it is used by other plugin types
resolve delegation
updated cache doc options
fixed test_script
better fragment merge for options
fixed proxy command
restore ini for proxy
normalized options
moved pipelining to class
updates for host_key_checking
restructured mixins

* fix typo
7 years ago
Toshio Kuratomi e8c599b0f7 Avoid re.split as it's a bit less efficient and a bit harder to read. 7 years ago
Matt Davis 5ff36c3423 Enable autoloading of inventory plugins (#32709)
* Automatically loads and executes an inventory plugin specified by a standard YAML inventory config file containing a `plugin` key at its root.
* Moved inventory PluginLoader to a shared global instance.
7 years ago
Toshio Kuratomi d166bba126 Fix non-ascii errors in config manager 7 years ago
Brian Coca c3564096cd
Inventory and varmanager updates (#32054)
* better parsing erros

* fix inventorydata serialization

* dicts fix
7 years ago
Brian Coca 506e6a0b2d removing deepcopy as it does not work
it cannot  handle deep crossreferenced objects
need to find alternative approach.
7 years ago
Brian Coca ab8bacdf5e make sure patterns are strings
fixes #31978
7 years ago
Brian Coca 383170e9e1 dont add all group vars to implicit on create
they already get added in vars manager on use.
fixes #31420
7 years ago
Brian Coca 2ffe3c42bb fixed caches (#30667) 7 years ago
Brian Coca 7fe6a8dab7 add all group vars back to implicit localhost
fixes #31857
reverts #31425
7 years ago
Jacob Floyd 0371d0deda Fix Inventory Plugin Loading (#31605)
This change makes the PluginLoader use DEFAULT_INVENTORY_PLUGIN_PATH setting.
Inventory Plugins were only being loaded the 'inventory_plugins' folder of the current directory,
as well as the ansible-provided inventory plugins (e.g. `/path/to/site-packages/ansible/plugins/inventory`).
7 years ago
Brian Coca a9942353fe revert ocalhost getting 'all' vars (#31425)
back to previous implicit localhost behaviour

fixes #31420
7 years ago
Brian Coca dbae704d3c correctd inventory_file to return full path
fixes #31294
7 years ago
Brian Coca 852d457549 turn all inventory cache 'off by default' 7 years ago
Brian Coca cf3414d7d7 set _hosts on access if None (#31111)
set _hosts on access if None to bpyass srlz10n issues to fix #30903
7 years ago
Brian Coca 3f9a885b83 use set to quicken group host membership 7 years ago
jctanner 5aebcd4f7f Remove redundant check for group membership in add_host (#30530) 7 years ago
Brian Coca fc9b44e021 clear correct cache when reconcile is invoked
moved it to ensure all callers get the correct hosts after
7 years ago
Brian Coca f87d0b3502 typo fix 7 years ago
Brian Coca 0571014f2f bypass get_hosts and use dictionary directly
removed redundant consistency fallback
inventory reconciliation already takes care of this a priori
removed unused imports
7 years ago
Brian Coca de6ba4daff add toggle to controle inventory parse as error (#28729)
* add toggle to controle inventory parse as error

also rearranged new inventory options into it's own ini section

* updated with inventory features

also minor fixes/consolidation on deprecated/removed modules

* tweaked settings
7 years ago
Brian Coca 95eaa246aa added keyed_group construction (#28578)
* added keyed_group construction

also added strict config to allow skipping bad templating
more precise error msgs
to_native better than to_text
fixed truthyness
added safe names

* allow keyed expressions to return lists

* PEPE should eat less, he is getting fat
7 years ago
Brian Coca f921369445 Ansible Config part2 (#27448)
* 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
7 years ago
Brian Coca 3a1b84153c ensure all groups inherit from 'all' 7 years ago
Brian Coca 661b2c5beb allow implicit host to be grouped (#26614)
* allow implicit host to be grouped

also optimized patternmatching

fixes #24156

* resolved a great crime
7 years ago
Matt Martz b6ee9163e3 Ensure hosts aren't duplicated in groups 7 years ago
Matt Martz 392934f1b9 Fix pep8 issue in lib/ansible/inventory/manager.py (#25562) 7 years ago
Brian Coca cc66bd4ad0 moved general pattern cache into object
no real reason this is a class global
7 years ago