1.RequestsDependencyWarning
(refer to http://blog.51cto.com/mjunetwslinux/2177727?source=dra)
python库中urllib3 (1.21.1) or chardet (2.2.1) 的版本不兼容
解决方法:
pip uninstall urllib3
pip uninstall chardet
pip install requests
2.在 /etc/ansible/hosts 已经配置了IP地址、用户名和密码登陆失败
临时解决方法:
禁用公钥认证
export ANSIBLE_HOST_KEY_CHECKING=False
手动登陆目标机器一次
ssh username@hostname
永久解决方法:
vim /etc/ansible/ansible.cfg
#host_key_checking= False取消注释
3.how to change to root at playbook
例1:target需要使用sudo su - 切换,则按照以下配置。
#site.yml
---
# This playbook deploys a simple playbook
- hosts: gcp
become_user: root
become: yes
become_method: su
roles:
- testplaybook1
#run playbook like this
ansible-playbook /appvol/ansible/ansible-examples/ansible_playbook_test/site.yml -u lihuanhuan80 --private-key /appvol/robin.private -e "ansible_become_exe='sudo su -'" -vvv
或者这样配置site.yml
---
# This playbook deploys a simple playbook
- hosts: gcp
become_user: root
become: yes
become_method: sudo
roles:
- testplaybook1
#run playbook like this
ansible-playbook /appvol/ansible/ansible-examples/ansible_playbook_test/site.yml -u lihuanhuan80 --private-key /appvol/robin.private -vvv
例2:target需要使用dzdo su - 切换,则按照以下配置。
#site.yml
---
# This playbook deploys a simple playbook
- hosts: gcp
become_user: root
become: yes
become_method: su
roles:
- testplaybook1
#run playbook like this
ansible-playbook /appvol/ansible/ansible-examples/ansible_playbook_test/site.yml -u lihuanhuan80 --private-key /appvol/robin.private -e "ansible_become_exe='dzdo su -'" -vvv
或者这样配置site.yml
---
# This playbook deploys a simple playbook
- hosts: gcp
become_user: root
become: yes
become_method: dzdo
roles:
- testplaybook1
#run playbook like this
ansible-playbook /appvol/ansible/ansible-examples/ansible_playbook_test/site.yml -u lihuanhuan80 --private-key /appvol/robin.private -vvv