尝试添加epel,然后在amazon-linux-2服务器上通过ansible执行yum更新。我使用的URL基于:https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/
我的ansible脚本是:
---
- hosts: all
remote_user: cloud_user
tasks:
- name: 01 add epel
yum_repository:
name: epel
description: EPEL YUM repo
baseurl: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
become: yes
- name: 02 yum update
yum: name=* state=latest
become: yes
我在任务02上的错误是(任务01有一个“更改”的通知):
FAILED! => {"changed": false, "msg": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm/repodata/repomd.xml:
[Errno 14] HTTPS Error 404 - Not Found\nTrying other mirror.\n\n\n One of the configured repositories failed (EPEL YUM repo),\n and yum doesn't have enough cached data to continue. At this point the only\n safe thing yum can do is fail. There are a few ways to work \"fix\" this:\n\n
1. Contact the upstream for the repository and get them to fix the problem.\n\n
2. Reconfigure the baseurl/etc. for the repository, to point to a working\n upstream. This is most often useful if you are using a newer\n distribution release than is supported by the repository (and the\n packages for the previous distribution release still work).\n\n
3. Run the command with the repository temporarily disabled\n yum --disablerepo=epel ...\n\n
4. Disable the repository permanently, so yum won't use it by default. Yum\n
will then just ignore the repository until you permanently enable it\n again or use --enablerepo for temporary usage:\n\n
yum-config-manager --disable epel\n
or\n
subscription-manager repos --disable=epel\n\n
5. Configure the failing repository to be skipped, if it is unavailable.\n Note that yum will try to contact the repo. when it runs most commands,\n
so will have to try and fail each time (and thus. yum will be be much\n
slower). If it is a very temporary problem though, this is often a nice\n
compromise:\n\n yum-config-manager --save --setopt=epel.skip_if_unavailable=true\n\nfailure: repodata/repomd.xml from epel:
[Errno 256] No more mirrors to try.\nhttps://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm/repodata/repomd.xml:
[Errno 14] HTTPS Error 404 - Not Found\n", "rc": 1, "results": []}
任何指导或帮助都是很棒的。
发布于 2020-05-24 05:57:00
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
不是yum存储库,它是一个yum包。
正如您在所链接的文档中所看到的,他们对其进行了yum install
:
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
然后,他们通过命令yum-config-manager
启用它
sudo yum-config-manager --enable epel
另一方面,https://dl.fedoraproject.org/pub/epel/$releasever/$basearch/
是一个yum存储库URL。
所以你的第一个任务应该是
- name: 01 add epel
yum_repository:
name: epel
description: EPEL YUM repo
baseurl: https://dl.fedoraproject.org/pub/epel/$releasever/$basearch/
become: yes
你的错误实际上说明了这一点:
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm/repodata/repomd.xml
查看它如何尝试获取文件夹repodata
和文件repomd.xml
现在,如果您浏览https://dl.fedoraproject.org/pub/epel/并查看文件夹7
,然后在任何子文件夹下,您将找到确切的repodata
文件夹和确切的repomd.xml
文件。
注意:可以找到有关变量$releasever
和$basearch
的额外信息:
此外,由于您的知识文章指导您使用版本7(请参阅epel-release-latest-7.noarch.rpm
中的7),因此您可以做的是将其作为属性传递给yum
任务。
- name: 02 yum update
yum:
name: '*'
state: latest
releasever: 7
become: yes
注意:我还改变了你的语法,我想说在同一本剧本中混合使用attribute=value和YAML语法是一个坏主意。
发布于 2020-05-25 11:32:55
要安装EPEL,只需从基础存储库安装epel-release
包就足够了。此外,考虑到建议尽可能不使用shell
或command
模块,我们可以通过直接更新配置文件来启用存储库。因此,我会提出以下建议:
- name: Install EPEL repository
yum:
name: epel-release
state: present
- name: Ensure EPEL repo is enabled
ini_file:
dest: /etc/yum.repos.d/epel.repo
section: epel
option: enabled
value: '1'
- name: Conduct yum update
yum:
name: *
state: latest
become: True
update_cache: True
发布于 2020-05-30 05:52:40
感谢您的所有投入。不确定这是否是amazon-linux-2的东西,但我得到的唯一一个是使用galaxy角色,代码如下:
roles:
- role: geerlingguy.repo-epel
vars:
epel_repo_url: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
epel_repo_gpg_key_url: "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7"
become: yes
https://stackoverflow.com/questions/61978672
复制相似问题