mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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
39
CHANGELOG.md
39
CHANGELOG.md
|
@ -48,27 +48,25 @@ Ansible Changes By Release
|
|||
module is deprecated and slated to go away in 2.8. The functionality has been
|
||||
moved to `ansible.utils.unsafe_proxy` to avoid a circular import.
|
||||
|
||||
#### Deprecated Modules:
|
||||
* ec2_facts (removed in 2.7), replaced by ec2_metadata_facts
|
||||
* cs_nic (removed in 2.7), replaced by cs_instance_nic_secondaryip, also see new module cs_instance_nic for managing nics
|
||||
* panos_address (use M(panos_object) instead)
|
||||
* panos_service (use M(panos_object) instead)
|
||||
* panos_security_policy: In 2.4 use M(panos_security_rule) instead.
|
||||
* panos_nat_policy, In 2.4 use M(panos_nat_rule) instead.
|
||||
* s3 (removed in 2.7), replaced by aws_s3
|
||||
#### Deprecated Modules (to be removed in 2.8):
|
||||
* ec2_facts: replaced by ec2_metadata_facts
|
||||
* cs_nic: replaced by cs_instance_nic_secondaryip, also see new module cs_instance_nic for managing nics
|
||||
* panos_address: use M(panos_object) instead
|
||||
* panos_service: use M(panos_object) instead
|
||||
* panos_security_policy: use M(panos_security_rule) instead
|
||||
* panos_nat_policy: use M(panos_nat_rule) instead
|
||||
* s3: replaced by aws_s3
|
||||
* ec2_remote_facts: replaced by
|
||||
|
||||
#### Removed Deprecated Modules:
|
||||
* eos_template (use eos_config instead)
|
||||
* ios_template (use ios_config instead)
|
||||
* iosxr_template (use iosxr_config instead)
|
||||
* junos_template (use junos_config instead)
|
||||
* nxos_template (use nxos_config instead)
|
||||
* ops_template (use ops_config instead)
|
||||
#### Removed Modules (previouslly deprecated):
|
||||
* eos_template: use eos_config instead
|
||||
* ios_template: use ios_config instead
|
||||
* iosxr_template: use iosxr_config instead
|
||||
* junos_template: use junos_config instead
|
||||
* nxos_template: use nxos_config instead
|
||||
* ops_template: use ops_config instead
|
||||
* openswitch
|
||||
|
||||
* Modules (scheduled for removal in 2.6)
|
||||
|
||||
* ec2_remote_facts
|
||||
|
||||
### Minor Changes
|
||||
* Removed previously deprecated config option `hostfile` and env var `ANSIBLE_HOSTS`
|
||||
|
@ -124,6 +122,11 @@ Ansible Changes By Release
|
|||
* datetime filter updated to use default format of datetime.datetime (ISO8601)
|
||||
* The junit plugin now has an option to report a junit test failure on changes for idempotent testing.
|
||||
* New 'diff' keyword allows setting diff mode on playbook objects, overriding command line option and config.
|
||||
* New config settings for inventory to:
|
||||
- control inventory plugins used
|
||||
- extensions of files to ignore when using inventory directory
|
||||
- patterns of flies to ignore when using inventory directory
|
||||
- option to toggle failed inventory source parsing between an error or a warning
|
||||
|
||||
#### New Callbacks:
|
||||
- full_skip
|
||||
|
|
|
@ -72,9 +72,6 @@
|
|||
# enable callback plugins, they can output to stdout but cannot be 'stdout' type.
|
||||
#callback_whitelist = timer, mail
|
||||
|
||||
# enable inventory plugins, default: 'host_list', 'script', 'yaml', 'ini'
|
||||
#inventory_enabled = host_list, virtualbox, yaml, constructed
|
||||
|
||||
# Determine whether includes in tasks and handlers are "static" by
|
||||
# default. As of 2.0, includes are dynamic by default. Setting these
|
||||
# values to True will make includes behave more like they did in the
|
||||
|
@ -313,6 +310,19 @@
|
|||
# set default errors for all plays
|
||||
#any_errors_fatal = False
|
||||
|
||||
[inventory]
|
||||
# enable inventory plugins, default: 'host_list', 'script', 'yaml', 'ini'
|
||||
#enabled_plugins = host_list, virtualbox, yaml, constructed
|
||||
|
||||
# ignore these extensions when parsing a directory as inventory source
|
||||
#ignore_extensions = '.pyc', '.pyo', '.swp', '.bak', '~', '.rpm', '.md', '.txt', '~', '.orig', '.ini', '.cfg', '.retry'
|
||||
|
||||
# ignore files matching these patterns when parsing a directory as inventory source
|
||||
#ignore_patterns=
|
||||
|
||||
# If 'true' unparsed inventory sources become fatal errors, they are warnings otherwise.
|
||||
#unparsed_is_failed=False
|
||||
|
||||
[privilege_escalation]
|
||||
#become=True
|
||||
#become_method=sudo
|
||||
|
|
|
@ -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,6 +267,14 @@ class InventoryManager(object):
|
|||
else:
|
||||
if not parsed and failures:
|
||||
# only if no plugin processed files should we show errors.
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue