ansible 错误记录(1)

基本环境:docker基于centos7

在docker里面安装ansible

不管是在root还是普通用户下执行 ansible all -m ping  都报如下错误:

172.20.1.1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Control socket connect(/home/hadoop/.ansible/ansible_control_path/55a69c5722): Connection refused\r\nFailed to connect to new control master",
"unreachable": true
}

上述报错的意思是说:控制套接字拒绝连接,不能连接新的控制主机:

解决办法:

在/etc/ansible/ansible.cfg文件下的[ssh_connection]下面添加如下值:

control_path_dir = /dev/shm/ansible_control_path

如果在/etc/ansible/ansible.cfg里面配置remote_user=root,那么在普通用户下执行ansible的时候,如果不指定远程用户,默认使用的是root用户,会提示权限被拒绝,如下:

这个时候想要执行成功,需要指定远程用户,使用-u选项,如下:

猜你喜欢

转载自www.cnblogs.com/yjt1993/p/10980172.html