## db-[99:101]-node.example.com
我在最后把我的一个服务器地址加入:
## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57
# Here's another example of host ranges, this time there are no
# leading 0s:
## db-[99:101]-node.example.com
192.168.61.129 #这是我加入的
接下来咱们运行咱们的第一条命令:
ansible '192.168.61.129' -m ping –k
报错误了,提示什么公钥,
-u:指定连接时的用户名,默认就是root,所以不加该选项也是可以的
-k:提示输入密码,是--ask-pass的简写形式
要不修改ansible.cfg配置文件的ask_pass = True给取消注释,要不就在运行命令时候加上-k,这个意思是-k, --ask-pass ask for SSH password。再修改:host_key_checking= False即可,我是直接ssh 192.168.61.129登陆了一次再执行就Ok 了
[root@taotao ansible]# ansible '192.168.61.129' -m ping -k
SSH password:
192.168.61.129 | FAILED! => {
"failed": true,
"msg":"Using a SSH password instead of a key is not possible because Host Keychecking is enabled and sshpass does not support this. Please add this host's fingerprint to yourknown_hosts file to manage this host."
ansible '192.168.61.129' -m shell -a 'date' –k 再来一个命令