Ansible學習筆記(六):Ansible使用時常見問題總結

1出現Error: ansible requires a json module, none found!

SSH password:

192.168.24.15 | FAILED >> {

   "failed": true,

   "msg": "Error: ansible requires a json module, nonefound!",

   "parsed": false

}

解決:python版本過低,要不升級python要不就安裝python-simplejson

2安裝完成後連接客戶端服務器報錯:

FAILED => Using a SSH password insteadof a key is not possible because Host Key checking is enabled and sshpass doesnot support this.  Please add this host'sfingerprint to your known_hosts file to manage this host.

解決:ansible 服務器上使用ssh 登陸下/etc/ansible/hosts 裏面配置的服務器。然後再次使用ansible 去管理就不會報上面的錯誤了!但這樣大批量登陸就麻煩來。因爲默認ansible是使用key驗證的,如果使用密碼登陸的服務器,使用ansible的話,要不修改ansible.cfg配置文件的ask_pass = True給取消註釋,要不就在運行命令時候加上-k,這個意思是-k, --ask-pass ask for SSH password。再修改:host_key_checking= False即可

3如果客戶端不在know_hosts裏將會報錯

paramiko: The authenticity of host '192.168.24.15'can't be established.

The ssh-rsa key fingerprint is397c139fd4b0d763fcffaee346a4bf6b.

Are you sure you want to continueconnecting (yes/no)?

解決:需要修改ansible.cfg#host_key_checking= False取消註釋

4出現FAILED => FAILED: not a valid DSA private key file

解決:需要你在最後添加參數-k

5openssh升級後無法登錄報錯

PAM unable todlopen(/lib64/security/pam_stack.so): /lib64/security/pam_stack.so: cannot openshared object

file: No such file or directory

解決:sshrpm 升級後會修改/etc/pam.d/sshd 文件。需要升級前備份此文件最後還原即可登錄。

6pip安裝完成後,運行ansible報錯:

File "/usr/lib64/python2.6/subprocess.py",line 642, in __init__ errread, errwrite)

解決:安裝:yum installopenssh-clients

7第一次系統初始化運行生成本機ansible用戶key時報錯

failed: [127.0.0.1] =>{"checksum": "f5f2f20fc0774be961fffb951a50023e31abe920","failed": true}

msg: Aborting, target uses selinux butpython bindings (libselinux-python) aren't installed!

FATAL: all hosts have already failed –aborting

解決:# yuminstall libselinux-python -y

8ansible無法起停tomcat的時候,有兩個點需要關注

1)環境變量,在startup.sh中添加source /etc/profile

2)後臺運行,加上nohup &


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章