mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 22:30:22 -07:00
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
This commit is contained in:
parent
862cde5e82
commit
de6ba4daff
4 changed files with 56 additions and 30 deletions
|
@ -1180,31 +1180,36 @@ HOST_KEY_CHECKING:
|
|||
ini:
|
||||
- {key: host_key_checking, section: defaults}
|
||||
type: boolean
|
||||
yaml: {key: defaults.host_key_checking}
|
||||
INVENTORY_ENABLED:
|
||||
default: [host_list, script, yaml, ini]
|
||||
default: ['host_list', 'script', 'yaml', 'ini']
|
||||
description: List of enabled inventory plugins, it also determines the order in which they are used.
|
||||
env: [{name: ANSIBLE_INVENTORY_ENABLED}]
|
||||
ini:
|
||||
- {key: inventory_enabled, section: defaults}
|
||||
- {key: enable_plugins, section: inventory}
|
||||
type: list
|
||||
yaml: {key: inventory.enabled_plugins}
|
||||
INVENTORY_IGNORE_EXTS:
|
||||
default: eval(BLACKLIST_EXTS + ( '~', '.orig', '.ini', '.cfg', '.retry'))
|
||||
description: List of extensions to ignore when using a directory as an inventory source
|
||||
env: [{name: ANSIBLE_INVENTORY_IGNORE}]
|
||||
ini:
|
||||
- {key: inventory_ignore_extensions, section: defaults}
|
||||
- {key: ignore_extensions, section: inventory}
|
||||
type: list
|
||||
yaml: {key: inventory.ignore_extensions}
|
||||
INVENTORY_IGNORE_PATTERNS:
|
||||
default: []
|
||||
description: List of patterns to ignore when using a directory as an inventory source
|
||||
env: [{name: ANSIBLE_INVENTORY_IGNORE_REGEX}]
|
||||
ini:
|
||||
- {key: inventory_ignore_patterns, section: defaults}
|
||||
- {key: ignore_patterns, section: inventory}
|
||||
type: list
|
||||
yaml: {key: inventory.ignore_patterns}
|
||||
INVENTORY_UNPARSED_IS_FAILED:
|
||||
default: False
|
||||
description: If 'true' unparsed inventory sources become fatal errors, they are warnings otherwise.
|
||||
env: [{name: ANSIBLE_INVENTORY_UNPARSED_FAILED}]
|
||||
ini:
|
||||
- {key: unparsed_is_failed, section: inventory}
|
||||
type: boolean
|
||||
MAX_FILE_SIZE_FOR_DIFF:
|
||||
default: 104448
|
||||
description: Maximum size of files to be considered for diff display
|
||||
|
|
|
@ -267,9 +267,17 @@ class InventoryManager(object):
|
|||
else:
|
||||
if not parsed and failures:
|
||||
# only if no plugin processed files should we show errors.
|
||||
for fail in failures:
|
||||
display.warning('\n* Failed to parse %s with %s plugin: %s' % (to_native(fail['src']), fail['plugin'], to_native(fail['exc'])))
|
||||
display.vvv(fail['exc'].tb)
|
||||
if C.INVENTORY_UNPARSED_IS_FAILED:
|
||||
msg = "Could not parse inventory source %s with availabel plugins:\n" % source
|
||||
for fail in failures:
|
||||
msg += 'Plugin %s failed: %s\n' % (fail['plugin'], to_native(fail['exc']))
|
||||
if display.verbosity >= 3:
|
||||
msg += "%s\n" % fail['exc'].tb
|
||||
raise AnsibleParserError(msg)
|
||||
else:
|
||||
for fail in failures:
|
||||
display.warning('\n* Failed to parse %s with %s plugin: %s' % (to_native(fail['src']), fail['plugin'], to_native(fail['exc'])))
|
||||
display.vvv(fail['exc'].tb)
|
||||
|
||||
if not parsed:
|
||||
display.warning("Unable to parse %s as an inventory source" % to_native(source))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue