Ansible安裝過程中常遇到的錯誤(FAQ)


1.安裝完成后允許命令報錯

Traceback (most recent call last):
  File "/usr/bin/ansible", line 197, in <module>
    (runner, results) = cli.run(options, args)
  File "/usr/bin/ansible", line 163, in run
    extra_vars=extra_vars,
  File "/usr/lib/python2.6/site-packages/ansible/runner/__init__.py", line 233, in __init__
    cmd = subprocess.Popen(['ssh','-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/usr/lib64/python2.6/subprocess.py", line 639, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.6/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

解決方法:

# yum install openssh-clients

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

SSH password:
10.0.1.110 | FAILED >> {
   "failed": true,
   "msg": "Error: ansible requires a json module, nonefound!",
   "parsed": false
}

解決方法:

python版本過低,要不升級python要不就升級安裝python-simplejson。

3.安裝完成后連接客戶端服務器報錯

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

4.如果客戶端不在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取消注釋

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

解決方法:

需要你在最后添加參數-k

6.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 文件。需要升級前備份此文件最后還原即可登錄。

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

解決方法:

# yum install libselinux-python -y

  

 

 

 

 

 

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM