当Ansible和Molecule无法正常运行时,采取的修复步骤备忘
ansible和分子不再运行时所采取的恢复步骤备忘录。
由于我个人的环境没有严格的管理,所以我没有注意到有一天ansible和molecule无法正常运行。
$ molecule list
Traceback (most recent call last):
File "/home/hogehoge/.local/bin/molecule", line 5, in <module>
from molecule.__main__ import main
ModuleNotFoundError: No module named 'molecule'
$ ansible --version
Traceback (most recent call last):
File "/home/hogehoge/.local/bin/ansible", line 34, in <module>
from ansible import context
ModuleNotFoundError: No module named 'ansible'
环境
Fedora Linux 35(工作站版)
以下的内容是关于引入了 molecule 和 ansible,但在引入时,Fedora 的版本应该更低。
$ python3 -m pip install --user "molecule[lint]"
$ python3 -m pip install --user "molecule[docker]"
试验各种不同的方法
$ python3 -m pip uninstall --user "molecule[lint]"
$ sudo dnf remove ansible
$ sudo dnf install ansible
可能还有其他不同的地方也在做的可能性。
最终恢复的步骤
由于存在问题,尽量删除后再重新安装,将~/.local目录迁移。
$ cd
$ mv .local .local.bk
$ python3 -m pip install --user "molecule[lint]"
$ python3 -m pip install --user "molecule[docker]"
$ python3 -m pip install --user ansible
$ ansible --version
ansible [core 2.11.6]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/hogehoge/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/hogehoge/.local/lib/python3.10/site-packages/ansible
ansible collection location = /home/hogehoge/.ansible/collections:/usr/share/ansible/collections
executable location = /home/hogehoge/.local/bin/ansible
python version = 3.10.0 (default, Oct 4 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]
jinja version = 3.0.1
libyaml = False
$ molecule --version
molecule 3.5.2 using python 3.10
ansible:2.11.6
delegated:3.5.2 from molecule
docker:1.1.0 from molecule_docker requiring collections: community.docker>=1.9.1
暂时放下心中的焦虑