ansible / ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://www.ansible.com/
GNU General Public License v3.0
62.37k stars 23.81k forks source link

ansible-inventory fails to parse netbox plugin in EE runner #81161

Closed HeroesLament closed 1 year ago

HeroesLament commented 1 year ago

Summary

Hello Ansible Team,

I'm faced with a strange situation. I'm trying to get our Ansible AWX environment pulling from our Netbox for dynamic inventory of VMs. When I test locally, I am able to pull a test VM tagged with "production", but when I run the exact same ansible-inventory on the runner, it fails to parse completely. Nearly identical versions on both environments, with the only difference I can find is the EE runner uses Python 3.11.2 compiled on GCC 8.5.0, and my local uses Python 3.11.3 compiled on GCC 13.1.1.

Issue Type

Bug Report

Component Name

module

Ansible Version

$ ansible --version
ansible [core 2.15.1]
  config file = /home/sypher/src/NetworkSysOps/tools/ansible-awx/ansible.cfg
  configured module search path = ['/home/sypher/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/sypher/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.3 (main, Jun  5 2023, 09:32:32) [GCC 13.1.1 20230429] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True
^^^^ Local PC
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.11/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-inventory
  python version = 3.11.2 (main, Feb 28 2023, 23:00:48) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True
^^^^ EE Runner

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /home/sypher/src/NetworkSysOps/tools/ansible-awx/ansible.cfg
DEFAULT_HOST_LIST(/home/sypher/src/NetworkSysOps/tools/ansible-awx/ansible.cfg) = ['/home/sypher/src/NetworkSysOps/tools/ansible-awx/netbox.yml']
^^^ Local PC
CONFIG_FILE() = /etc/ansible/ansible.cfg
^^^ Runner EE

OS / Environment

Local: Garuda Linux, LTS Kernel Runner EE: Redhat UBI 8, base image quay.io/ansible/ansible-runner:stable-2.12-latest, modified to latest versions of Ansible and Python.

Steps to Reproduce

ansible-inventory -vvvv --list -i /runner/project/tools/ansible-awx/netbox.yml

Expected Results

ansible-inventory [core 2.15.1]
  config file = /home/sypher/src/NetworkSysOps/tools/ansible-awx/ansible.cfg
  configured module search path = ['/home/sypher/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/sypher/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-inventory
  python version = 3.11.3 (main, Jun  5 2023, 09:32:32) [GCC 13.1.1 20230429] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /home/sypher/src/NetworkSysOps/tools/ansible-awx/ansible.cfg as config file
setting up inventory plugins
Loading collection ansible.builtin from 
host_list declined parsing /home/sypher/src/NetworkSysOps/tools/ansible-awx/netbox.yml as it did not pass its verify_file() method
script declined parsing /home/sypher/src/NetworkSysOps/tools/ansible-awx/netbox.yml as it did not pass its verify_file() method
Loading collection netbox.netbox from /home/sypher/.ansible/collections/ansible_collections/netbox/netbox
Using inventory plugin 'ansible_collections.netbox.netbox.plugins.inventory.nb_inventory' to process inventory source '/home/sypher/src/NetworkSysOps/tools/ansible-awx/netbox.yml'
Fetching: http://netbox.alpha.gg:8008/api/status
Fetching: http://netbox.alpha.gg:8008/api/dcim/devices/?limit=0&tag=production&exclude=config_context
Fetching: http://netbox.alpha.gg:8008/api/virtualization/virtual-machines/?limit=0&tag=production&exclude=config_context
Fetching: http://netbox.alpha.gg:8008/api/dcim/sites/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/dcim/regions/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/dcim/site-groups/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/dcim/locations/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/tenancy/tenants/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/dcim/device-roles/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/dcim/platforms/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/dcim/device-types/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/dcim/manufacturers/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/virtualization/clusters/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/ipam/services/?limit=0
Fetching: http://netbox.alpha.gg:8008/api/dcim/racks/?limit=0
Parsed /home/sypher/src/NetworkSysOps/tools/ansible-awx/netbox.yml inventory source with auto plugin
{
    "_meta": {
        "hostvars": {
            "rtr-lhr-01": {
                "cluster": "London 1",
                "cluster_type": "vultr",
                "custom_fields": {},
                "device_roles": [
                    "router"
                ],
                "disk": 60,
                "is_virtual": true,
                "local_context_data": [
                    null
                ],
                "locations": [],
                "memory": 2048,
                "regions": [],
                "services": [],
                "site_groups": [],
                "sites": [
                    "vultr-lhr-01"
                ],
                "status": {
                    "label": "Active",
                    "value": "active"
                },
                "tags": [
                    "production"
                ],
                "vcpus": 2.0
            }
        }
    },
    "all": {
        "children": [
            "ungrouped",
            "tags_production"
        ]
    },
    "tags_production": {
        "hosts": [
            "rtr-lhr-01"
        ]
    }
}

Actual Results

ansible-inventory [core 2.15.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.11/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections:/usr/share/automation-controller/collections
  executable location = /usr/local/bin/ansible-inventory
  python version = 3.11.2 (main, Feb 28 2023, 23:00:48) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Loading collection ansible.builtin from 
host_list declined parsing /runner/project/tools/ansible-awx/netbox.yml as it did not pass its verify_file() method
script declined parsing /runner/project/tools/ansible-awx/netbox.yml as it did not pass its verify_file() method
Loading collection netbox.netbox from /home/runner/.ansible/collections/ansible_collections/netbox/netbox
Using inventory plugin 'ansible_collections.netbox.netbox.plugins.inventory.nb_inventory' to process inventory source '/runner/project/tools/ansible-awx/netbox.yml'
Fetching: http://netbox.alpha.gg:8008/api/status
toml declined parsing /runner/project/tools/ansible-awx/netbox.yml as it did not pass its verify_file() method
[WARNING]:  * Failed to parse /runner/project/tools/ansible-awx/netbox.yml with
    return Version(version)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/packaging/version.py", line 196, in __init__
    match = self._regex.search(version)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[WARNING]:  * Failed to parse /runner/project/tools/ansible-awx/netbox.yml with
yaml plugin: Plugin configuration YAML file, not YAML inventory
  File "/usr/local/lib/python3.11/site-packages/ansible/inventory/manager.py", line 293, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/local/lib/python3.11/site-packages/ansible/plugins/inventory/yaml.py", line 114, in parse
    raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
[WARNING]:  * Failed to parse /runner/project/tools/ansible-awx/netbox.yml with
ini plugin: Invalid host pattern '---' supplied, '---' is normally a sign this
is a YAML file.
  File "/usr/local/lib/python3.11/site-packages/ansible/inventory/manager.py", line 293, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/local/lib/python3.11/site-packages/ansible/plugins/inventory/ini.py", line 137, in parse
    raise AnsibleParserError(e)
[WARNING]: Unable to parse /runner/project/tools/ansible-awx/netbox.yml as an
inventory source
ERROR! No inventory was parsed, please check your configuration and options.

Code of Conduct

ansibot commented 1 year ago

Files identified in the description: None

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibot commented 1 year ago

@HeroesLament: Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information.

Here are the items we could not find in your description:

Please set the description of this issue with an appropriate template from: https://github.com/ansible/ansible/tree/devel/.github/ISSUE_TEMPLATE

click here for bot help

HeroesLament commented 1 year ago

!component inventory

HeroesLament commented 1 year ago

!component +lib/ansible/inventory/

ansibot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

bcoca commented 1 year ago

Hi!

Thanks very much for your interest in Ansible. It means a lot to us.

This appears to be a user question, and we'd like to direct these kinds of things to either the mailing list or the IRC channel.

See this page for a complete and up to date list of communication channels and their purposes:

Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time. If don't you think this particular issue is resolved, you should still stop by there first, we'd appreciate it. This allows us to keep the issue tracker for bugs, pull requests, RFEs and the like.

Thank you once again and we look forward to seeing you on the list or IRC. Thanks!