我尝试使用netbox IPAM作为信任源来获取动态Ansible库存。但是使用netbox广告资源插件执行ansible-inventory
时出现错误。
root@server:/opt/ansible/projects/customer# ansible --version
ansible 2.7.4
config file = /opt/ansible/projects/customer/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible-2.7.4-py2.7.egg/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516]
ansible.cfg
inventory_plugins = /opt/ansible/plugins/plugin_type/inventory_plugins
[inventory]
# enable inventory plugins, default: 'host_list', 'script', 'yaml', 'ini', 'auto'
enable_plugins = netbox, ini, yaml, auto
netbox_inventory2.yaml
name: netbox
plugin_type: inventory
short_description: Netbox Inventory Source
plugin: netbox
api_endpoint: https://localhost:8000
token: ‘token’
validate_certs: False
group_by:
- device_roles
这是错误消息:
ansible-inventory -vvv --list -i netbox_inventory2.yaml
ansible-inventory 2.7.4
config file = /opt/ansible/projects/customer/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible-2.7.4-py2.7.egg/ansible
executable location = /usr/local/bin/ansible-inventory
python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516]
Using /opt/ansible/projects/customer/ansible.cfg as config file
ERROR! Unexpected Exception, this is probably a bug: 'module' object has no attribute 'InventoryModule'
the full traceback was:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ansible-2.7.4-py2.7.egg/EGG-INFO/scripts/ansible-inventory", line 118, in <module>
exit_code = cli.run()
File "/usr/local/lib/python2.7/dist-packages/ansible-2.7.4-py2.7.egg/ansible/cli/inventory.py", line 137, in run
self.loader, self.inventory, self.vm = self._play_prereqs(self.options)
File "/usr/local/lib/python2.7/dist-packages/ansible-2.7.4-py2.7.egg/ansible/cli/__init__.py", line 786, in _play_prereqs
inventory = InventoryManager(loader=loader, sources=options.inventory)
File "/usr/local/lib/python2.7/dist-packages/ansible-2.7.4-py2.7.egg/ansible/inventory/manager.py", line 145, in __init__
self.parse_sources(cache=True)
File "/usr/local/lib/python2.7/dist-packages/ansible-2.7.4-py2.7.egg/ansible/inventory/manager.py", line 196, in parse_sources
self._setup_inventory_plugins()
File "/usr/local/lib/python2.7/dist-packages/ansible-2.7.4-py2.7.egg/ansible/inventory/manager.py", line 184, in _setup_inventory_plugins
plugin = inventory_loader.get(name)
File "/usr/local/lib/python2.7/dist-packages/ansible-2.7.4-py2.7.egg/ansible/plugins/loader.py", line 381, in get
obj = getattr(self._module_cache[path], self.class_name)
AttributeError: 'module' object has no attribute 'InventoryModule'
我知道该模块应该可以工作,但是我找不到我的错误。