我的旁白剧使用hashivault_read
。我在Mac上安装了此模块。当我尝试执行剧本时,此任务会出错,提示No module named hvac
。当我看到pip list
时,可以在Mac上找到该模块。
有人在Mac上遇到过此问题吗?如果有人对此有解决方案,请发表评论。
Ansible Properties
ansible-playbook 2.8.0
config file = /Users/mdhoke/ansible.cfg
configured module search path = [u'/Users/mdhoke/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Python/2.7/site-packages/ansible
executable location = /usr/local/bin/ansible-playbook
python version = 2.7.10 (default, Feb 22 2019, 21:55:15) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)]
我认为ansible正在尝试在hvac
下找到/Library/Python/2.7/site-packages/ansible
模块,该模块不存在,但存在hashivault_read
。
hvac
下有/Library/Python/2.7/site-packages
个模块。
我得到的错误:
fatal: [vault]: FAILED! => {"changed": false, "module_stderr": "Shared connection to vault closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/home/mdhoke/.ansible/tmp/ansible-tmp-1567120470.9-210430890667193/AnsiballZ_hashivault_read.py\", line 114, in <module>\r\n _ansiballz_main()\r\n File \"/home/mdhoke/.ansible/tmp/ansible-tmp-1567120470.9-210430890667193/AnsiballZ_hashivault_read.py\", line 106, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/home/mdhoke/.ansible/tmp/ansible-tmp-1567120470.9-210430890667193/AnsiballZ_hashivault_read.py\", line 49, in invoke_module\r\n imp.load_module('__main__', mod, module, MOD_DESC)\r\n File \"/tmp/ansible_hashivault_read_payload_kE0iQk/__main__.py\", line 3, in <module>\r\n File \"/tmp/ansible_hashivault_read_payload_kE0iQk/ansible_hashivault_read_payload.zip/ansible/module_utils/hashivault.py\", line 4, in <module>\r\n
ImportError: No module named hvac\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
答案 0 :(得分:0)
昨天我设法为自己解决了这个问题。我假设您正在从Mac本地运行ansible,并连接到远程服务器(保管库)。如果是这样,您还需要在Vault服务器上安装hvac。
下面的代码段就足够了
- name: install hvac pip package
become: yes
become_method: sudo
pip:
name: hvac
state: present
显然,要使上述游戏正常运行,您还需要在Vault服务器上安装python-pip,并且要安装它,您需要启用epel-release。下面的代码将解决这些依赖关系。
- name: enable epel-relase and install pip
become: yes
become_method: sudo
yum:
name: "{{ item }}"
state: present
with_items:
- epel-release
- python-pip
答案 1 :(得分:0)
实际上,hashivault_read
模块应该在本地计算机上执行。因此,将其委托给本地计算机解决了我的问题。