无法使用 ansible zypper 命令安装 rpm 包
Posted
技术标签:
【中文标题】无法使用 ansible zypper 命令安装 rpm 包【英文标题】:Unable to install rpm package using ansible zypper command 【发布时间】:2021-01-22 15:31:56 【问题描述】:问题:
代码:
---
- name: Upgrade package to latest version on all OS VMs
hosts: all_OS
tasks:
- name: Copy 11 rpm file to server
copy:
src: /tmp/package/package-v1.4-1.OStype11.rpm
dest: /tmp/
when: ansible_distribution == "OStype" and ansible_distribution_major_version == "v1"
- name: Install 11 rpm on server
zypper:
name: /tmp/package-v1.4-1.OStype11.rpm
#update_cache: yes
force: yes
state: present
when: ansible_distribution == "OStype" and ansible_distribution_major_version == "v1"
错误:
fatal: [dummy]: FAILED! => "changed": false, "cmd": ["/usr/bin/zypper", "--quiet", "--non-interactive", "--xmlout", "install", "--type", "package", "--auto-agree-with-licenses", "--no-recommends", "--force", "--", "/tmp/package-v1.4-1.OStype12.2.rpm"], "msg": "Zypper run command failed with return code 4.", "rc": 4, "stderr": "", "stderr_lines": [], "stdout": "<?xml version='1.0'?>\n<stream>\n<message type=\"error\">Download (curl) error for 'https://site/infrastructure_agent/OS/zypp/OStype/12.2/x86_64/repodata/repomd.xml':\nError code: Connection failed\nError message: Failed to connect to site port 443: Connection timed out\n</message>\n<prompt id=\"8\">\n<text>Abort, retry, ignore?</text>\n<option default=\"1\" value=\"a\" desc=\"Skip retrieval of the file and abort current operation.\"/>\n<option value=\"r\" desc=\"Try to retrieve the file again.\"/>\n<option value=\"i\" desc=\"Skip retrieval of the file and try to continue with the operation without the file.\"/>\n<option value=\"u\" desc=\"Change current base URI and try retrieving the file again.\"/>\n<option value=\"s\" desc=\"Disable SSL certificate authority check and continue.\"/>\n</prompt>\n<prompt id=\"8\">\n<text>Abort, retry, ignore?</text>\n<option default=\"1\" value=\"a\" desc=\"Skip retrieval of the file and abort current operation.\"/>\n<option value=\"r\" desc=\"Try to retrieve the file again.\"/>\n<option value=\"i\" desc=\"Skip retrieval of the file and try to continue with the operation without the file.\"/>\n<option value=\"u\" desc=\"Change current base URI and try retrieving the file again.\"/>\n</prompt>\n<message type=\"error\">ABORT request: Aborting requested by user</message>\n</stream>\n", "stdout_lines": ["<?xml version='1.0'?>", "<stream>", "<message type=\"error\">Download (curl) error for 'https://site/infrastructure_agent/OS/zypp/OStype/12.2/x86_64/repodata/repomd.xml':", "Error code: Connection failed", "Error message: Failed to connect to site port 443: Connection timed out", "</message>", "<prompt id=\"8\">", "<text>Abort, retry, ignore?</text>", "<option default=\"1\" value=\"a\" desc=\"Skip retrieval of the file and abort current operation.\"/>", "<option value=\"r\" desc=\"Try to retrieve the file again.\"/>", "<option value=\"i\" desc=\"Skip retrieval of the file and try to continue with the operation without the file.\"/>", "<option value=\"u\" desc=\"Change current base URI and try retrieving the file again.\"/>", "<option value=\"s\" desc=\"Disable SSL certificate authority check and continue.\"/>", "</prompt>", "<prompt id=\"8\">", "<text>Abort, retry, ignore?</text>", "<option default=\"1\" value=\"a\" desc=\"Skip retrieval of the file and abort current operation.\"/>", "<option value=\"r\" desc=\"Try to retrieve the file again.\"/>", "<option value=\"i\" desc=\"Skip retrieval of the file and try to continue with the operation without the file.\"/>", "<option value=\"u\" desc=\"Change current base URI and try retrieving the file again.\"/>", "</prompt>", "<message type=\"error\">ABORT request: Aborting requested by user</message>", "</stream>"]
【问题讨论】:
您能否用您已经尝试过但无法解决错误的任何方法更新您的问题? @Adam 是的,我做了很多谷歌搜索,但似乎 SLES 上的 zypper 包问题?如果有人有任何解决方法,请寻求帮助。我可以使用命令模块并运行 rpm 包,但这不是运行 ansible 剧本的有效方式。 【参考方案1】:Error message: Failed to connect to download.newrelic.com port 443: Connection timed out
似乎它试图下载一些额外的文件。尝试在测试环境中手动安装此包以查看完整错误。
或者也许出站到 download.newrelic.com 的 443 端口被防火墙了?
【讨论】:
以上是关于无法使用 ansible zypper 命令安装 rpm 包的主要内容,如果未能解决你的问题,请参考以下文章