簡體   English   中英

python3的Ansible模塊問題

[英]Ansible module issue with python3

下午好,我有一個通過 pip3 安裝的 pymongo 模塊,現在我正在嘗試使用它

- name: Create role for pbm
  community.mongodb.mongodb_shell:
    login_host: 10.0.44.40
    eval: 'db.getSiblingDB ("admin"). createRole ({"role": "pbmAnyAction", "privileges": [{"resource": {"anyResource": true}, "actions": ["anyAction"] }], "roles": []}); '
  vars:
    ansible_python_interpreter: / usr / bin / python3
  ignore_errors: yes
  when: groups.mongodb.index (inventory_hostname) == 0

並且在我的本地 vagrant vm 上一切正常,但是當我在生產 vm 上運行它時,出現錯誤

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pymongo.errors
fatal: [mongodb-01]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (pymongo) on superproduction-mongo-01's Python / usr / bin / python. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter "}

vagrant 和 production 的操作系統版本相同(centos 7)

python3 版本輸出並從生產虛擬機導入 pymongo.errors

 python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo.errors
>>> 

來自流浪虛擬機

python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo.errors
>>>

如您所見,輸出相同

即使我什么都沒做也能工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM