需要 Ansible consul 模块但已安装

需要 Ansible consul 模块但已安装

我已经创建了简单的任务来在 Consul 中添加键值,但是出现了错误:

    ansible-playbook -i hosts -u siecadm master_playbook.yml

PLAY [consul] **************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************
ok: [lxxxxxx.xxx.rxx.xxx]

TASK [hello_world : Bare include (free-form)] ******************************************************************************************************
ok: [lxxxxxx.xxx.rxx.xxx]

TASK [hello_world : Hello World !!!!] **************************************************************************************************************
changed: [lxxxxxx.xxx.rxx.xxx]

TASK [add_keysValues : Bare include (free-form)] ***************************************************************************************************
ok: [lxxxxxx.xxx.rxx.xxx]

TASK [add_keysValues : Add Key Values In Consul] ***************************************************************************************************
fatal: [lxxxxxx.xxx.rxx.xxx]: FAILED! => {"changed": false, "msg": "python-consul required for this module. see https://python-consul.readstallation"}
        to retry, use: --limit @/home/sietadm/ansible/ansible_repo/consul_create_KeyValue/master_playbook.retry

PLAY RECAP *****************************************************************************************************************************************
lxxxxxx.xxx.rxx.xxx : ok=4    changed=1    unreachable=0    failed=1

但是模块已经安装好了,我已经成功了

    sudo pip install python-consul
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: python-consul in /usr/local/lib/python2.7/dist-packages (1.1.0)
Requirement already satisfied: six>=1.4 in /usr/lib/python2.7/dist-packages (from python-consul) (1.10.0)
Requirement already satisfied: requests>=2.0 in /usr/local/lib/python2.7/dist-packages (from python-consul) (2.20.1)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/lib/python2.7/dist-packages (from requests>=2.0->python-consul) (1.24.2)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python2.7/dist-packages (from requests>=2.0->python-consul) (3.0.4)
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python2.7/dist-packages (from requests>=2.0->python-consul) (2.7)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/dist-packages (from requests>=2.0->python-consul) (2019.3.9)


whereis python
python: /usr/bin/python3.5m-config /usr/bin/python3.5-config /usr/bin/python3.5m /usr/bin/python2.7-config /usr/bin/python3.5 /usr/bin/python /usr/bin/python2.7 /usr/lib/python3.5 /usr/lib/python2.7 /etc/python3.5 /etc/python /etc/python2.7 /usr/local/lib/python3.5 /usr/local/lib/python2.7 /usr/include/python3.5m /usr/include/python3.5 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz

感谢帮助

答案1

python-consul 需要安装在执行模块的机器上(即远程主机,除非您使用 delegate_to 或类似的东西。该信息在此处指定:https://docs.ansible.com/ansible/latest/modules/consul_module.html)。

还要确保远程主机上的 ansible 使用的是 python2,而不是远程主机上的 python3。

答案2

我找到了解决方案,你应该在远程服务器上安装模块 python-consul

编辑:为什么要投反对票?

谢谢

相关内容