Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with keyed_group group name transformation #53714

Merged
merged 1 commit into from Mar 14, 2019

Conversation

AlanCoding
Copy link
Member

SUMMARY

If I used the setting to transform group names, it throws an error if keyed_groups are used, and those go over some groups with transformed characters

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

inventory plugin constructible

ADDITIONAL INFORMATION

Reproduce with

ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS=false ansible-inventory -i aws_ec2.yaml --list --export -vvv

Where you are using keyed groups like

plugin: aws_ec2
keyed_groups:
  - prefix: ""
    separator: ""
    key: placement.availability_zone
    parent_group: zones

you get errors like

 [WARNING]:  * Failed to parse /Users/alancoding/Documents/repos/ansible-inventory-file-examples/private/ec2/aws_ec2.yaml with auto plugin: us-east-2 is not a known group

  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/inventory/manager.py", line 272, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/plugins/inventory/auto.py", line 58, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/plugins/inventory/aws_ec2.py", line 570, in parse
    self._populate(results, hostnames)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/plugins/inventory/aws_ec2.py", line 465, in _populate
    self._add_hosts(hosts=groups[group], group=group, hostnames=hostnames)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/plugins/inventory/aws_ec2.py", line 500, in _add_hosts
    self._add_host_to_keyed_groups(self.get_option('keyed_groups'), host, hostname, strict=strict)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/plugins/inventory/__init__.py", line 424, in _add_host_to_keyed_groups
    self.inventory.add_child(gname, host)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/inventory/data.py", line 270, in add_child
    raise AnsibleError("%s is not a known group" % group)

This makes it work again with the setting on that.

ping @bcoca

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. inventory Inventory category needs_triage Needs a first human triage before being processed. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Mar 12, 2019
@bcoca bcoca merged commit db3a268 into ansible:devel Mar 14, 2019
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Mar 14, 2019
@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. inventory Inventory category small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants