gmdzxx 发表于 2018-1-2 21:35:08

Ansible常见问题处理

  1、ansible all -m ping报错,信息如下:
: 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的这个主机安装
$ ansible 192.168.0.107 -m shell -a "rm -rf /tmp/1.txt"
: Consider using file module with state=absent rather than running rm
  192.168.0.107 | SUCCESS | rc=0 >>
页: [1]
查看完整版本: Ansible常见问题处理