Error: ansible requires a json module, none found

Error: ansible requires a json module, none found

执行 ansible ping 模块时出错

bash ~ ansible webservers  -i inventory -m ping  -k  -u root -vvvv
SSH password: 
<~> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO ~
<my-lnx> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO my-lnx
~ | FAILED => FAILED: [Errno 8] nodename nor servname provided, or not known
<my-lnx> REMOTE_MODULE ping
<my-lnx> EXEC /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1423302966.66-77716810353582 && echo $HOME/.ansible/tmp/ansible-tmp-1423302966.66-77716810353582'
<my-lnx> PUT /var/folders/8n/fftvnbbs51q834y16vfvb1q00000gn/T/tmpP6zwZj TO /root/.ansible/tmp/ansible-tmp-1423302966.66-77716810353582/ping
<my-lnx> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1423302966.66-77716810353582/ping; rm -rf /root/.ansible/tmp/ansible-tmp-1423302966.66-77716810353582/ >/dev/null 2>&1'
my-lnx | FAILED >> {
    "failed": true, 
    "msg": "Error: ansible requires a json module, none found!", 
    "parsed": false
}

这是我的库存文件

bash ~ cat inventory 
[webservers]
my-lnx  ansible_ssh_host=my-lnx ansible_ssh_port=22

我也在客户端和远程机器上安装了 simplejosn 模块

bash ~ pip list | grep json
simple-json (1.1)
simplejson (3.6.5)

我认为您需要安装 python-simplejson 模块。

先尝试运行这个命令,然后再尝试你想要的命令:

 ansible webservers -i inventory -m raw -a "sudo yum install -y python-simplejson"  -k  -u root -vvvv

我假设它是旧的红色 Hat/CentOS 系统。

如果您不想或不能在远程服务器上安装 python-simplejson 模块,您可以简单地请求原始输出:

> ansible webservers -i inventory -m ping -m raw

或者像我一样,将它添加到我的 ~/.bash_profile

alias ansible="ansible -m raw"

# And then simply running:
> ansible webservers -i inventory -m ping

在 centos 5.* 版本号 python-简单 json 可在 repo 上下载和安装。你可以简单地使用下面提到的方法。

确保源和目标都应该少密码访问,并且从源到目标也少密码。

使用 ssh-keygen -t rsa 生成密钥 ssh-copy-id user@host_ip

"--- - 主机:(可靠的主机) 成为:是的 remote_user: 根 gather_facts: 错误 任务: - 名称:copying copying temps shell: ssh (源) && rsync -parv /root/temp/* root@(目标):/root/temp/"