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 >>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值