我正在尝试开始使用 ansible,所以我正在浏览简介。我已经使用 apt-get 在 Debian Jessie 上安装了 ansible。它显示版本 2.2
我已经配置了 /etc/ansible/hosts 文件如下:
test ansible_connection=local
如果我跑
ansible all -m ping
我得到了一个乐观的结果:
测试 | 成功 => { "changed": false, "ping": "pong" }
但是当我尝试(如介绍所建议)运行最原始的命令时:
ansible all -a "/bin/echo hello"
我感到非常失望
任务执行期间发生异常。要查看完整回溯,请使用 -vvv。错误为:NameError:全局名称“MODULE_ARGS”未定义测试 | FAILED | rc=0 >> MODULE FAILURE
当我用 -vvv 运行它时,我得到
Using /etc/ansible/ansible.cfg as config file
Using module file /usr/share/ansible/commands/command
<test> ESTABLISH LOCAL CONNECTION FOR USER: my-username
<test> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464972944.68-67450526741064 `" && echo ansible-tmp-1464972944.68-67450526741064="` echo $HOME/.ansible/tmp/ansible-tmp-1464972944.68-67450526741064 `" ) && sleep 0'
<test> PUT /tmp/tmpTcFA7W TO /home/my-username/.ansible/tmp/ansible-tmp-1464972944.68-67450526741064/command
<test> EXEC /bin/sh -c 'chmod -R u+x /home/my-username/.ansible/tmp/ansible-tmp-1464972944.68-67450526741064/ && sleep 0'
<test> EXEC /bin/sh -c 'LANG=C LC_ALL=C LC_MESSAGES=C /usr/bin/python /home/my-username/.ansible/tmp/ansible-tmp-1464972944.68-67450526741064/command; rm -rf "/home/my-username/.ansible/tmp/ansible-tmp-1464972944.68-67450526741064/" > /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_771nna/ansible_module_command.py", line 243, in <module>
main()
File "/tmp/ansible_771nna/ansible_module_command.py", line 117, in main
module = CommandModule(argument_spec=dict())
File "/usr/local/lib/python2.7/dist-packages/ansible-2.2.0-py2.7.egg/ansible/module_utils/basic.py", line 616, in __init__
self._load_params()
File "/tmp/ansible_771nna/ansible_module_command.py", line 204, in _load_params
args = MODULE_ARGS
NameError: global name 'MODULE_ARGS' is not defined
test | FAILED | rc=0 >>
MODULE FAILURE
我做错了什么?非常感谢!
答案1
好的,在这种情况下,安装过程中似乎出了问题。我已经完成了
sudo apt-get remove ansible
然后
pip install ansible
现在上面的命令已经成功运行了!