diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aafdf1c56..c7cfd8f0da 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/examples/ansible.cfg b/examples/ansible.cfg index 7abae073f2..fa73d4a514 100644 --- a/examples/ansible.cfg +++ b/examples/ansible.cfg @@ -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 diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml index a1c2d8f925..d3a7a7b742 100644 --- a/lib/ansible/config/base.yml +++ b/lib/ansible/config/base.yml @@ -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 diff --git a/lib/ansible/inventory/manager.py b/lib/ansible/inventory/manager.py index 8e94c6ad2c..1591a773f3 100644 --- a/lib/ansible/inventory/manager.py +++ b/lib/ansible/inventory/manager.py @@ -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))