Mac*_*iej 14 ssl ansible ansible-galaxy ubuntu-18.04
开始学习 Ansible 并希望简化ansible-galaxy search nginx命令,但我得到:
ERROR! Unknown error when attempting to call Galaxy at 'https://galaxy.ansible.com/api/api': <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)>
Run Code Online (Sandbox Code Playgroud)
曾尝试使用ansible-galaxy --ignore-certs search nginx但ansible-galaxy -c search nginx现在正在寻找ansible-galaxy: error: unrecognized arguments: --ignore-certs摊位。
操作系统:
发行商 ID:Ubuntu 描述:Ubuntu 18.04.5 LTS 版本:18.04 代号:bionic
安斯波版本:
ansible 2.9.5
config file = /home/maciej/projects/priv/ansible_nauka/packt_course/ansible.cfg
configured module search path = ['/home/maciej/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/maciej/.local/lib/python3.6/site-packages/ansible
executable location = /home/maciej/.local/bin/ansible
python version = 3.6.9 (default, Jul 17 2020, 12:50:27) [GCC 8.4.0]
Run Code Online (Sandbox Code Playgroud)
neh*_*r.t 26
我也遇到了同样的问题,但是是在 Mac OS X 上。
根本问题是您的 Python 环境未找到/使用操作系统上安装的默认根证书。需要这些根证书才能与 Ansible Galaxy 安全连接(通过 TLS)。
对于 Mac OS X,我能够根据这个答案解决这个问题: How to make Python use CAcertificates from Mac OS TrustStore?
即通过运行脚本来安装证书,随安装一起提供:
cd /Applications/Python\ 3.7/
./Install\ Certificates.command
Run Code Online (Sandbox Code Playgroud)
(你的Python版本可能不同)
对于 Ubuntu/Debian:
更新:正如 Maciej 在接受的答案中指出的那样,可以重新生成证书并将其添加到环境中:
sudo update-ca-certificates --fresh
export SSL_CERT_DIR=/etc/ssl/certs
Run Code Online (Sandbox Code Playgroud)
PS:我不建议使用--ignore-certs,这会跳过 TLS 连接中的证书验证,使连接不安全(允许中间人攻击)
回到这个问题……生活是最好的动力。对我有帮助的是:
sudo update-ca-certificates --fresh
export SSL_CERT_DIR=/etc/ssl/certs
Run Code Online (Sandbox Code Playgroud)