天天看點

Ansible安裝過程中遇到過的問題

from: http://www.ansible.cn/forum.php?mod=viewthread&tid=67&extra=page%3D1

今天大緻看了下ansible,如果花時間自己用shell也能寫一個。ansible 需要用到sshpass,密碼也是明文儲存,

不是很安全。CenOS6.4下,直接yum -y install ansible 就能安裝。

FAQ

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

5、openssh更新後無法登入報錯

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 檔案。需要更新前備份此檔案最後還原即可登入。

6、pip安裝完成後,運作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 but pythonbindings (libselinux-python) aren't installed!

FATAL: all hosts have already failed –aborting

解決:# yuminstall libselinux-python -y

注意這個是在 host機器上安裝,不是在ansible控制機器上。

繼續閱讀