ansible问题汇总

  1. ansible -i hosts 111 -m shell -a "whoami",执行出现以下报错。
  2. 0.0.0.0 | UNREACHABLE! => {
        "changed": false, 
        "msg": "Failed to connect to the host via ssh: \nI wrote it myself!\n\nansible@0.0.0.0: Permission denied (publickey,password,keyboard-interactive).", 
        "unreachable": true
    }
  3. 原因:hosts配置文件不正确。
  4. 解决:修改配置最后三行如下:
  5. [all:vars]        //all代表全部,如果有别的名称请灵活更改
    ansible_user=账号
    ansible_ssh_pass=密码
    ansible_sudo_pass=‘root密码’    //这里写su切换root,root的密码,如有需要则写
    ansible_ssh_port=端口           //登如果要指定端口登陆,则这里添加,无则不写

 二

  1. 初次安装ansible运行可能会出现的错误:如图
  2. 0.0.0.0 | FAILED | rc=-1 >>
    Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host.
  3. 原因:第一次连接主机需要输入yes确认,可以修改ansible.cfg文件来解决这个问题。
  4. 修改以下配置:     host_key_checking = False
  5. 默认在第71行,去掉注释即可。

 三

  1. 正常执行ansible报如下错误。
  2. 0.0.0.0 | FAILED | rc=-1 >>
    failed to transfer file to /home/ansible/.ansible/tmp/ansible-local-88903hW16i/tmp62jKAj /home/ansible/.ansible/tmp/ansible-tmp-1621569719.26-141234726549106/AnsiballZ_command.py:
    
    dd: error writing ‘/home/ansible/.ansible/tmp/ansible-tmp-1621569719.26-141234726549106/AnsiballZ_command.py’: No space left on device
    1+0 records in
    0+0 records out
    0 bytes (0 B) copied, 0.00513831 s, 0.0 kB/s
    
    [WARNING]: piped transfer mechanism failed on [0.0.0.0]. Use ANSIBLE_DEBUG=1 to see detailed information
    
    
    注意报错有以下字样: 即都是磁盘没有空间导致。
    【No space left on device\n】
  3.  原因:很明显是写错误,说明对方服务磁盘没空间了。
  4. 解决:上去报错的服务器,清理相关磁盘空间即可。

 四

1.执行命令报这个错:

ansible  -i hosts 111 -b -f 2 -m shell -a "whoami"

0.0.0.0 | FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to 0.0.0.0 closed.\r\n",
    "module_stdout": "\r\nsudo: pam_authenticate: Module is unknown\r\n",
    "msg": "MODULE FAILURE",
    "rc": 1
}

2.原因:-b参数切换root用户没有权限

3.解决:在hosts文件里边添加一条参数:

[all:vars]
ansible_ssh_port=22
ansible_ssh_user=ansible
ansible_ssh_pass='123123'
ansible_sudo_pass='123456'    //这行是添加上去的。有个漏洞,root密码明文,不安全

 五

1.执行命令报这个错:

ansible  -i hosts 123 -m shell -a "whoami"

255.255.255.255 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nIT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\r\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\r\nIt is also possible that a host key has just been changed.\r\nThe fingerprint for the RSA key sent by the remote host is\nSHA256:wdCWlfhJUkSvIlyoLDtdhnrqOgApgVnOxVuEmsYXkg0.\r\nPlease contact your system administrator.\r\nAdd correct host key in /root/.ssh/known_hosts to get rid of this message.\r\nOffending ECDSA key in /root/.ssh/known_hosts:97\r\nPassword authentication is disabled to avoid man-in-the-middle attacks.\r\nKeyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.\r\nAuthorized users only. All activity may be monitored and reported\nWXJD_ludan@192.168.6.50: Permission denied (publickey,password).", 
    "unreachable": true

2.原因:ssh密钥出问题了

3.解决:

       vim /root/.ssh/known_hosts

       找到255.255.255.255这台主机的密钥,把他删除掉,即可解决问题。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值