我们管理系统,从而管理存储库。我们删除了我们不使用的存储库,存在于/etc/yum.repos.d/<file>
我们的问题是:在系统更新/升级后,CentOS 会自动重新创建被删除的存储库,这对我们来说是一个问题。
问题:是否有命令/方法可以确保在 CentOS 7 系统上升级后不会重新创建存储库。
这些存储库是由某人创建的,操作系统不会重新创建它们。
它们要么通过 RPM 包的更新来恢复,要么通过centos-release
您设置/运行的自动脚本(ansible?)来恢复。
我不知道删除 repo 的自动方法;我看到了几个解决方案:
centos-release
通过添加
exclude=centos-release
到/etc/yum.conf
(空格分隔列表)从可升级包中排除,但这可能会破坏一些更新;
禁用它们:
# yum-config-manager --disable base,updates,extras,centosplus,epel,whatever
(这可以很容易地编写脚本并放入 cron 或您的 ansible playbook 中)
编写一个小脚本并将其放在 中/etc/cron.hourly/
,例如/etc/cron.hourly/wipe_repos
,包含:
#!/usr/bin/env bash
rm -f /etc/yum.repos.d/CentOS-Base.repo
或更好:
#!/usr/bin/env bash
yum-config-manager --disable base,updates,extras,centosplus,epel,whatever
我建议使用解决方案 2,因为 repo 文件不会被更新覆盖,但新版本会与旧的 in.rpmnew
文件一起放置。
这是由 的%config(noreplace)
源 rpm 中的标志保证的centos-release
,应用于/etc/yum.repos.d/
. 您可以通过下载 .src.rpm 并打开centos-release.spec
文件来检查这一点。
$ mkdir test && cd test
$ yumdownloader --source centos-release
$ rpm2cpio centos-release*.rpm | cpio -idmv
$ cat centos-release.spec
(或者网上搜索包下载src.rpm)
然后向下滚动到部分%files
,您会注意到:
%config(noreplace) /etc/yum.repos.d/*
%config(noreplace)
意味着所有这些文件都不会被更新中的新文件替换,但是来自新 rpm 的文件以扩展名保存.rpmnew
,因此您将拥有:
$ ls /etc/yum.repos.d/
CentOS-Base.repo <-- here you set them as disabled
CentOS-Base.repo.rpmnew <-- this comes from the update, but yum will ignore it
如需参考,请参阅http://people.ds.cam.ac.uk/jw35/docs/rpm_config.html或https://serverfault.com/a/48819/。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句