然而,在RHEL 6操作系统中,由于OpenSSH版本过于陈旧,可能不支持ControlPersist。在这些操作系统,Ansible将使用名为paramikoPython实现的OpenSSH调用。如果需要实现类似Kerberized SSH等高级功能,考虑使用Fedora, OS X或Ubuntu等使用了新版本OpenSSH的操作系统。
192.168.1.2 | UNREACHABLE! => {
"changed": false,
"msg": "ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue",
"unreachable": true
}
192.168.1.3 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.1.1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
# as bruce
$ ansible all -m ping -u bruce
# as bruce, sudoing to root
$ ansible all -m ping -u bruce --sudo
# as bruce, sudoing to batman
$ ansible all -m ping -u bruce --sudo --sudo-user batman
# With latest version of ansible `sudo` is deprecated so use become
# as bruce, sudoing to root
$ ansible all -m ping -u bruce -b
# as bruce, sudoing to batman
$ ansible all -m ping -u bruce -b --become-user batman
下面我们来测试一个简单的命令,向所有主机发送uname -a指令
ansible all -a "uname -a"
192.168.1.2 | UNREACHABLE! => {
"changed": false,
"msg": "ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue",
"unreachable": true
}
192.168.1.3 | SUCCESS | rc=0 >>
Linux host3.exmaple.com 2.6.32-504.16.2.el6.x86_64 #1 SMP Wed Apr 22 06:48:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
192.168.1.2 | SUCCESS | rc=0 >>
Linux host2.exmaple.com 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64 x86_64 GNU/Linux