Ansible常见问题处理

1、ansible all -m ping报错,信息如下:

[WARNING]: log file at /var/log/ansible.log is not writeable and we cannot create it, aborting

192.168.0.200 | UNREACHABLE! => {

    "changed": false,

    "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",

    "unreachable": true

}

解决方法:

(1)权限问题造成的,在/etc/ansible/hosts 中配置如下信息

192.168.0.200 ansible_user=root

之前配置的只有192.168.0.200,没有后面的那个信息,然后造成这样的错误问题

(2)在配置文件ansible.cfg中启用remote_user = root,则就不用再hosts文件中配置ansible_user=root了

说明:ansible_user=root

使用/usr/bin/ansible-playbook链接的默认用户名,如果不指定,会使用当前登录的用户名

 

2、 "msg": "Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!"

原因分析:托管节点上开启了SElinux,你需要安装libselinux-python,这样才可使用Ansible中与copy/file/template相关的函数.你可以通过Ansible的yum模块在需要的托管节点上安装libselinux-python.

解决方法:ansible all -m shell -a "yum -y install libselinux-python"

注意:是在远程管理的主机上安装,不是运行ansible的这个主机安装

[user@localhost ~]$ ansible 192.168.0.107 -m shell -a "rm -rf /tmp/1.txt"

 [WARNING]: Consider using file module with state=absent rather than running rm

192.168.0.107 | SUCCESS | rc=0 >>

 

posted @   哈喽哈喽111111  阅读(7090)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示