Skip to content

Unexpected result with force_valid_group_names #206

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

Closed
metabsd opened this issue May 14, 2020 · 6 comments
Closed

Unexpected result with force_valid_group_names #206

metabsd opened this issue May 14, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@metabsd
Copy link
Contributor

metabsd commented May 14, 2020

ISSUE TYPE
  • Bug Report
SOFTWARE VERSIONS
Ansible:

2.9.6

Netbox:

2.7.11

Collection:

nb_inventory.py

SUMMARY

I’m using nb_inventory.py I see https://url/api/dcim/devices/?limit=0&role=netinfra-tor in the debug log after I see Replacing invalid character(s) "{'-'}" in group name (device_roles_netinfra-tor)because I use group_by: device_roles and I use the same ansible.cfg that you provide from github project. During the execution of the inventory script.
Thx in advance!

STEPS TO REPRODUCE
plugin: netbox.netbox.nb_inventory
validate_certs: False
config_context: True
services: False
group_by:
  - device_roles
  - sites
  - platforms
compose:
  status: status.label
  owner: custom_fields.owner.label
query_filters:
  - role: netinfra-tor
  - role: netinfra-tor-dr
  - role: netinfra-tor-pe
  - tag : tona-dev
timeout: 180

Using this ansible.cfg

[defaults]
force_valid_group_names = always

[inventory]
enable_plugins = netbox.netbox.nb_inventory, auto, host_list, yaml, ini, toml, script
EXPECTED RESULTS

Automatic renaming group from invalid char to _

ACTUAL RESULTS
[WARNING]:  * Failed to parse
/tmp/awx_57306_qf07_i8z/project/inventories/netbox_inventory_sync_dev.yml with
auto plugin: Could not find group device_roles_netinfra-tor in inventory
  File "/opt/cust_venv/iaas_na/lib/python3.6/site-packages/ansible/inventory/manager.py", line 280, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/opt/cust_venv/iaas_na/lib/python3.6/site-packages/ansible/plugins/inventory/auto.py", line 58, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/tmp/awx_57306_qf07_i8z/requirements_collections/ansible_collections/netbox/netbox/plugins/inventory/nb_inventory.py", line 915, in parse
    self.main()
  File "/tmp/awx_57306_qf07_i8z/requirements_collections/ansible_collections/netbox/netbox/plugins/inventory/nb_inventory.py", line 884, in main
    self.add_host_to_groups(host=host, hostname=hostname)
  File "/tmp/awx_57306_qf07_i8z/requirements_collections/ansible_collections/netbox/netbox/plugins/inventory/nb_inventory.py", line 836, in add_host_to_groups
    self.inventory.add_host(group=group_name, host=hostname)
  File "/opt/cust_venv/iaas_na/lib/python3.6/site-packages/ansible/inventory/data.py", line 202, in add_host
    raise AnsibleError("Could not find group %s in inventory" % group)
[WARNING]:  * Failed to parse
/tmp/awx_57306_qf07_i8z/project/inventories/netbox_inventory_sync_dev.yml with
yaml plugin: Plugin configuration YAML file, not YAML inventory
  File "/opt/cust_venv/iaas_na/lib/python3.6/site-packages/ansible/inventory/manager.py", line 280, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/opt/cust_venv/iaas_na/lib/python3.6/site-packages/ansible/plugins/inventory/yaml.py", line 112, in parse
    raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
[WARNING]:  * Failed to parse
/tmp/awx_57306_qf07_i8z/project/inventories/netbox_inventory_sync_dev.yml with
ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not
allowed, this character is reserved to provide a port.
  File "/opt/cust_venv/iaas_na/lib/python3.6/site-packages/ansible/inventory/manager.py", line 280, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/opt/cust_venv/iaas_na/lib/python3.6/site-packages/ansible/plugins/inventory/ini.py", line 138, in parse
    raise AnsibleParserError(e)
[WARNING]: Unable to parse
/tmp/awx_57306_qf07_i8z/project/inventories/netbox_inventory_sync_dev.yml as an
inventory source
ERROR! No inventory was parsed, please check your configuration and options
@DouglasHeriot
Copy link
Contributor

DouglasHeriot commented May 15, 2020

This is fixed in #155 on the devel branch. There hasn't been a release with it yet.

You'll still get Replacing invalid character(s) "{'-'}" in group name in the verbose logs, but it will be handled correctly.

@metabsd
Copy link
Contributor Author

metabsd commented May 15, 2020

Can I help in any way for the next release :)

@FragmentedPacket
Copy link
Contributor

@metabsd Hey sorry for such a slow response. I was travelling and visiting family.

There are two PRs including the one you're after that I will try and review either tonight or tomorrow.

Again, sorry for the delay!

@FragmentedPacket FragmentedPacket added the bug Something isn't working label May 19, 2020
@metabsd
Copy link
Contributor Author

metabsd commented May 19, 2020

Good evening, I would like to know if I can lend a hand. I would like to participate in your project. Thank you for everything you do for the community. It is very generous of you.

@FragmentedPacket
Copy link
Contributor

@metabsd You're more than welcome to assign any issues to yourself and start working on them or reviewing any current PRs that are ready for review.

@FragmentedPacket
Copy link
Contributor

@metabsd New release has been cut for this v0.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants