Ansible命令模块无法执行参数。

15

一个 Ansible 初学者在此。

我遇到的问题是,当我使用“command”模块来执行命令时,它会失败。在远程主机和本地主机上都尝试过。

基本信息:

版本:ansible 2.0.0(开发版2c9d1257ba)

核心:(分离头文件5983d64d77),最后更新时间为2015年05月30日07:22:33(GMT +800)

额外组件:(分离头文件1276420a3a),最后更新时间为2015年05月30日07:22:41(GMT +800)

Ansible 主机文件

local   ansible_ssh_host=127.0.0.1  ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=a

命令

ansible -i ansible_hosts -m command -a "/usr/bin/ls" local

实际结果

local | FAILED! => {u'msg': u'Traceback (most recent call last):\r\n 
File
"/root/.ansible/tmp/ansible-tmp-1436165888.5-23845581569171/command",
line 2139, in <module>\r\n    main()\r\n  File
"/root/.ansible/tmp/ansible-tmp-1436165888.5-23845581569171/command",
line 158, in main\r\n    module =
CommandModule(argument_spec=dict())\r\n  File
"/root/.ansible/tmp/ansible-tmp-1436165888.5-23845581569171/command",
line 606, in __init__\r\n    self._check_for_check_mode()\r\n  File
"/root/.ansible/tmp/ansible-tmp-1436165888.5-23845581569171/command",
line 1142, in _check_for_check_mode\r\n    for (k,v) in
self.params.iteritems():\r\nAttributeError: \'tuple\' object has no
attribute \'iteritems\'\r\n', u'failed': True, u'changed': False,
u'parsed': False, u'invocation': {u'module_name': u'command',
u'module_args': {u'_raw_params': u'/usr/bin/ls'}}}

我的配置有问题吗?


1
IRC中的用户Halberom指出,在执行git pull时,子模块没有被拉取,从而导致主存储库-子模块存储库不同步。通过运行git submodule update --init --recursive问题得到解决。 - Eng Cheng
1
所以这个问题解决了吗? - michaelbahr
1
我投票关闭此问题,因为显然通过更新git子模块已解决该问题。 - Bruce P
1个回答

1

看起来这个问题是通过在正在使用的 Ansible 检出中运行 git submodule update --init --recursive 来解决的。

如果其他人遇到相同的问题,最简单的解决方法是从主机的系统包管理器安装 Ansible,或者在 virtualenv 中运行 pip install Ansible


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接