Ansible 动态库存自 mac os 更新后不起作用
Ansible Dynamic Inventory Doesn't work since mac os update
我在星期三安装了最新的 mac os 更新 10.15.7,从那时起我的 ansible 动态库存停止工作。我最初怀疑安装多个 python 有问题,后来了解到 Python 内部开发工具 mac 需要 2.7 和 3.7。我的目前在 Python 3.8.6 上,所有 pip 包都已安装。
在我安装 mac 更新之前一直有效。
下面是完整的堆栈跟踪错误。
$ 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'
如果有人能够解决此问题,请告诉我。 TIA :)
您正在使用 ansible 2.10。 ec2 inventory 源插件不再是核心 ansible 的一部分。您需要安装对应的合集:
ansible-galaxy collection install amazon.aws
参考:https://docs.ansible.com/ansible/latest/collections/amazon/aws/aws_ec2_inventory.html
我在星期三安装了最新的 mac os 更新 10.15.7,从那时起我的 ansible 动态库存停止工作。我最初怀疑安装多个 python 有问题,后来了解到 Python 内部开发工具 mac 需要 2.7 和 3.7。我的目前在 Python 3.8.6 上,所有 pip 包都已安装。
在我安装 mac 更新之前一直有效。
下面是完整的堆栈跟踪错误。
$ 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'
如果有人能够解决此问题,请告诉我。 TIA :)
您正在使用 ansible 2.10。 ec2 inventory 源插件不再是核心 ansible 的一部分。您需要安装对应的合集:
ansible-galaxy collection install amazon.aws
参考:https://docs.ansible.com/ansible/latest/collections/amazon/aws/aws_ec2_inventory.html