赞
踩
当前环境:ansible 运行在docker容器当中,并且可以连接对应的机器
$ ansible all -m ping
server1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Control socket connect(/root/.ansible/cp/570a47a2a4): Connection refused\r\nFailed to connect to new control master\r\n",
"unreachable": true
}
修改ansible的默认连接方式 为paramiko解决此类问题
$ ansible all -m ping -c paramiko
server1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
python3.6 ansible的inventory的文件在/usr/local/lib/python3.6/site-packages/ansible/galaxy/data/default/tests目录下面
[root@codo-cmdb tests]# pwd
/usr/local/lib/python3.6/site-packages/ansible/galaxy/data/apb/tests
[root@codo-cmdb tests]# ls
inventory test.yml.j2
修改对应的配置信息
如果你想用ssh mode ,而不是 paramiko, 你需要修改如下配置信息
vi /usr/local/lib/python3.6/site-packages/ansible/galaxy/data/apb/tests/ansible.cfg
[defaults]
inventory=./inventory
transport = ssh
host_key_checking = False
[ssh_connection]
ssh_args =
scp_if_ssh = True
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。