猿问

Ansible 中的回溯错误(Python 版本不匹配?)

运行以下命令时出现回溯错误


ansible-playbook -i hosts fmg-playbooks/01_add_model_device.yml

我正在运行 Ansible 2.9 和 Python 3.6.5


ansible 2.9.11

  config file = /home/alice/ansible/ansible.cfg

  configured module search path = ['/home/alice/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']

  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible

  executable location = /usr/local/bin/ansible

  python version = 3.6.5 (default, Apr  1 2018, 05:46:30) [GCC 7.3.0]


我收到有关 Python 版本的警告




TASK [Gathering Facts] ***************************************************************************************************************************************************************************************

[DEPRECATION WARNING]: Distribution Ubuntu 18.04 on host fmg01 should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release

will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information. This feature will be

removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

ok: [fmg01]

然后当我尝试添加设备时,出现回溯错误


TASK [Add model device] **************************************************************************************************************************************************************************************

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.connection.ConnectionError: Method not found

这可能是 Ansible 使用错误的 Python 解释器的问题吗?我可以强制它使用与 2.7 不同的版本吗?


jeck猫
浏览 139回答 1
1回答

跃然一笑

Python 版本没问题。事实证明这是端口的问题。我在我的主机文件中切换到 443,它开始工作了。[FMG:vars]ansible_network_os      = fortinet.fortimanager.fortimanageransible_httpapi_port    = 443ansible_httpapi_use_ssl = Trueansible_httpapi_validate_certs = Falseansible_connection = httpapi
随时随地看视频慕课网APP

相关分类

Python
我要回答