Ansible从rpm包安装yum repo [关闭]
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ansible从rpm包安装yum repo [关闭]相关的知识,希望对你有一定的参考价值。
我正在尝试使用Ansible安装rpm包。但是,我无法弄清楚如何正确地做到这一点。我希望有人可以帮助我。
这是我到目前为止所做的:
1.使用yum_repository模块(尝试1)
- name: "Setting up percona repository"
yum_repository:
name: "Percona"
description: "Percona yum repository"
baseurl: "http://www.percona.com/downloads/percona-release/redhat/latest/percona-release-0.1-4.noarch.rpm"
- name: "Installing PMM client package"
yum: pkg={{item}} state=installed
with_items:
- pmm-client
结果
TASK [pmmhosts : Setting up percona repository] **********************************************************************
changed: [server1]
changed: [server2]
TASK [pmmhosts : Installing PMM client package] **********************************************************************
failed: [server1] (item=[u'pmm-client']) => {"changed": false, "item": ["pmm-client"], "msg": "Failure talking to yum: failure: repodata/repomd.xml from Percona: [Errno 256] No more mirrors to try.
http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for Percona: Damaged repomd.xml file"}
failed: [server2] (item=[u'pmm-client']) => {"changed": false, "item": ["pmm-client"], "msg": "Failure talking to yum: failure: repodata/repomd.xml from Percona: [Errno 256] No more mirrors to try.
http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for Percona: Damaged repomd.xml file"}
2.使用yum_repository模块(尝试2)
- name: "Setting up percona repository"
yum_repository:
name: "Percona"
description: "Percona yum repository"
baseurl: "http://www.percona.com/downloads/percona-release/redhat/latest/"
- name: "Installing PMM client package"
yum: pkg={{item}} state=installed
with_items:
- pmm-client
结果
TASK [pmmhosts : Setting up percona repository] **********************************************************************
changed: [server1]
changed: [server2]
TASK [pmmhosts : Installing PMM client package] **********************************************************************
failed: [server1] (item=[u'pmm-client']) => {"changed": false, "item": ["pmm-client"], "msg": "Failure talking to yum: failure: repodata/repomd.xml from Percona: [Errno 256] No more mirrors to try.
http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for Percona: Damaged repomd.xml file"}
failed: [server2] (item=[u'pmm-client']) => {"changed": false, "item": ["pmm-client"], "msg": "Failure talking to yum: failure: repodata/repomd.xml from Percona: [Errno 256] No more mirrors to try.
http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for Percona: Damaged repomd.xml file"}
3.使用shell模块(试一试)
- name: "Setting up percona repository"
shell: "yum install -y http://www.percona.com/redir/downloads/percona-release/redhat/latest/percona-release-0.1-4.noarch.rpm"
- name: "Installing PMM client package"
yum: pkg={{item}} state=installed
with_items:
- pmm-client
结果(运行1)
TASK [pmmhosts : Setting up percona repository] **********************************************************************
changed: [server1]
changed: [server2]
TASK [pmmhosts : Installing PMM client package] **********************************************************************
changed: [server1] => (item=[u'pmm-client'])
changed: [server2] => (item=[u'pmm-client'])
结果(运行2)
TASK [pmmhosts : Setting up percona repository] **********************************************************************
fatal: [server1]: FAILED! => {"changed": true, "cmd": "yum install -y http://www.percona.com/redir/downloads/percona-release/redhat/latest/percona-release-0.1-4.noarch.rpm", "delta": "0:00:01.363009", "end": "2018-02-28 16:31:23.728102", "msg": "non-zero return code", "rc": 1, "start": "2018-02-28 16:31:22.365093", "stderr": "Error: Nothing to do", "stderr_lines": ["Error: Nothing to do"], "stdout": "Loaded plugins: fastestmirror
Examining /var/tmp/yum-root-5raeIL/percona-release-0.1-4.noarch.rpm: percona-release-0.1-4.noarch
/var/tmp/yum-root-5raeIL/percona-release-0.1-4.noarch.rpm: does not update installed package.", "stdout_lines": ["Loaded plugins: fastestmirror", "Examining /var/tmp/yum-root-5raeIL/percona-release-0.1-4.noarch.rpm: percona-release-0.1-4.noarch", "/var/tmp/yum-root-5raeIL/percona-release-0.1-4.noarch.rpm: does not update installed package."]}
fatal: [server2]: FAILED! => {"changed": true, "cmd": "yum install -y http://www.percona.com/redir/downloads/percona-release/redhat/latest/percona-release-0.1-4.noarch.rpm", "delta": "0:00:01.363009", "end": "2018-02-28 16:31:23.728102", "msg": "non-zero return code", "rc": 1, "start": "2018-02-28 16:31:22.365093", "stderr": "Error: Nothing to do", "stderr_lines": ["Error: Nothing to do"], "stdout": "Loaded plugins: fastestmirror
Examining /var/tmp/yum-root-5raeIL/percona-release-0.1-4.noarch.rpm: percona-release-0.1-4.noarch
/var/tmp/yum-root-5raeIL/percona-release-0.1-4.noarch.rpm: does not update installed package.", "stdout_lines": ["Loaded plugins: fastestmirror", "Examining /var/tmp/yum-root-5raeIL/percona-release-0.1-4.noarch.rpm: percona-release-0.1-4.noarch", "/var/tmp/yum-root-5raeIL/percona-release-0.1-4.noarch.rpm: does not update installed package."]}
结论:
到目前为止,使用yum_repository模块,我正在成功安装存储库。但是,我无法从此存储库获取任何包,因此无法再进行“yum install”。另一方面,使用shell模块,我可以第一次安装存储库,然后安装包正常运行。但是,由于已安装的存储库错误,我无法再次重现状态。
答案
我将修改你第三次尝试使用yum
模块来安装Percona rpm,它设置存储库并安装所需的GPG密钥,这些密钥可以有效地工作:
- name: "Setting up percona repository"
yum:
name: "http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm"
state: present
- name: Installing PMM client package...
....
以上是关于Ansible从rpm包安装yum repo [关闭]的主要内容,如果未能解决你的问题,请参考以下文章
7.6 yum更换国内源 7.7 yum下载rpm包 7.8/7.9 源码包安装