I installed the latest mac os update 10.15.7 on Wednesday and since then my ansible dynamic inventory stopped working. I was initially suspecting issue with multiple python installed and later understood Python 2.7 and 3.7 are required by the mac for internal dev-tools. Mine is currently on Python 3.8.6 and all the pip packages are installed.
This was working until I installed the mac update.
Below is the full stack trace error.
$ ansible help -vvv
ansible 2.10.2
config file = /Users/vamshisiddarthgaddam/workspace/_ansible/ansible.cfg
configured module search path = ['/Users/vamshisiddarthgaddam/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.8.6 (default, Oct 8 2020, 14:06:32) [Clang 12.0.0 (clang-1200.0.32.2)]
Using /Users/vamshisiddarthgaddam/workspace/_ansible/ansible.cfg as config file
redirecting (type: inventory) ansible.builtin.aws_ec2 to amazon.aws.aws_ec2
ERROR! Unexpected Exception, this is probably a bug: No module named 'ansible.plugins.inventory.aws_ec2'
the full traceback was:
Traceback (most recent call last):
File "/usr/local/bin/ansible", line 123, in <module>
exit_code = cli.run()
File "/usr/local/lib/python3.8/site-packages/ansible/cli/adhoc.py", line 97, in run
loader, inventory, variable_manager = self._play_prereqs()
File "/usr/local/lib/python3.8/site-packages/ansible/cli/__init__.py", line 467, in _play_prereqs
inventory = InventoryManager(loader=loader, sources=options['inventory'])
File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 166, in __init__
self.parse_sources(cache=True)
File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 224, in parse_sources
parse = self.parse_source(source, cache=cache)
File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 263, in parse_source
parsed_this_one = self.parse_source(fullpath, cache=cache)
File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 275, in parse_source
for plugin in self._fetch_inventory_plugins():
File "/usr/local/lib/python3.8/site-packages/ansible/inventory/manager.py", line 203, in _fetch_inventory_plugins
plugin = inventory_loader.get(name)
File "/usr/local/lib/python3.8/site-packages/ansible/plugins/loader.py", line 780, in get
return self.get_with_context(name, *args, **kwargs).object
File "/usr/local/lib/python3.8/site-packages/ansible/plugins/loader.py", line 800, in get_with_context
self._module_cache[path] = self._load_module_source(name, path)
File "/usr/local/lib/python3.8/site-packages/ansible/plugins/loader.py", line 764, in _load_module_source
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/vamshisiddarthgaddam/workspace/_ansible/lib/plugins/inventory_plugins/aws_ec2_custom.py", line 3, in <module>
from ansible.plugins.inventory.aws_ec2 import *
ModuleNotFoundError: No module named 'ansible.plugins.inventory.aws_ec2'
Let me know if anyone was able to fix this. TIA :)
You are using ansible 2.10. The ec2 inventory source plugin is not part of the core ansible anymore. You need to install the corresponding collection:
ansible-galaxy collection install amazon.aws
Reference: https://docs.ansible.com/ansible/latest/collections/amazon/aws/aws_ec2_inventory.html