[SOLVED] Prevent yum to change the content of /etc/yum.repos.d
[SOLVED] Prevent yum to change the content of /etc/yum.repos.d
Dear All,
In my /etc/yum.repos.d directory, the default .repo files (e.g. CentOS-Base.repo) are replaced by custom files pointing to a local repository.
Sometimes, when doing an update, yum reinstalls the default .repo files.
Is there a way to protect the content of /etc/yum.repos.d while keeping the yum package up to date ?
In my /etc/yum.repos.d directory, the default .repo files (e.g. CentOS-Base.repo) are replaced by custom files pointing to a local repository.
Sometimes, when doing an update, yum reinstalls the default .repo files.
Is there a way to protect the content of /etc/yum.repos.d while keeping the yum package up to date ?
Last edited by drknut on 2021/05/15 11:39:00, edited 1 time in total.
Re: Prevent yum to change the content of /etc/yum.repos.d
It should never replace modified files in that directory, they are all marked as config,noreplace in the spec file. It will however, put them back if they are removed.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: Prevent yum to change the content of /etc/yum.repos.d
That is a good solution.
I did use to edit files manually. Error-prone.
Yum-utils has tool for it:
Code: Select all
sudo yum-config-manager --disable base updates extras
Code: Select all
- name: Disable upstream base mirrors
ini_file:
dest: /etc/yum.repos.d/CentOS-Base.repo
section: "{{ item }}"
option: enabled
value: "0"
with_items:
- base
- updates
- extras
Code: Select all
- name: Add {{ site_name | upper }} base
yum_repository:
name: "{{ site_name }}-base"
description: CentOS $releasever - $basearch - {{ site_name | upper }}
file: "{{ site_name }}-mirror"
baseurl: "{{ site_mirror }}/$releasever/os/$basearch/"
gpgcheck: yes
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-{{ ansible_distribution_major_version }}
metadata_expire: 7d
Re: Prevent yum to change the content of /etc/yum.repos.d
It works, but it disables all repos having sections like [base] [updates] [extra], so it disables my custom repos too.jlehtone wrote: ↑2021/05/15 07:37:04Yum-utils has tool for it:Code: Select all
sudo yum-config-manager --disable base updates extras
Luckily there is an option (-c) to specify the config file. One at time, because it fails on duplicate sections.
[edit] This doesn't work, see my post below
For me, it translates to
Code: Select all
for f in /etc/yum.repos.d/CentOS*; do yum-config-manager -c $f '--disablerepo=*'; done
Of course, none of my custom files begins with 'CentOS'.
Thank you for your help, jlehtone.
Last edited by drknut on 2021/05/15 12:17:30, edited 1 time in total.
Re: [SOLVED] Prevent yum to change the content of /etc/yum.repos.d
The "solution" posted above, based on yum-config-manager, doesn't work at all.
Why ? because the enable/disable function needs a line with "enabled =" in the target section.
yum-config-manager doesn't add such a line if it is missing.
So my final solution is, so far
Why ? because the enable/disable function needs a line with "enabled =" in the target section.
yum-config-manager doesn't add such a line if it is missing.
So my final solution is, so far
Code: Select all
for f in /etc/yum.repos.d/CentOS*; do truncate -s 0 $f; done
Re: Prevent yum to change the content of /etc/yum.repos.d
If you have [base] in more than once, then your repositoryid's are not unique.man yum.conf wrote:repositoryid Must be a unique name for each repository, one word.
That problem is your own doing.
You were disabling CentOS repositories. Are there any that do not have the 'enabled' option?
Furthermore, the "--disable" does add the 'enabled = 0'.
(The "--enable" does not add the missing 'enabled' option because the default is enabled.)
The yum-config-manager is fully functional unless the input data is garbage.
Re: Prevent yum to change the content of /etc/yum.repos.d
Your are totally right. I plead guilty of not RTFM.
You probably never do that, so feel free to throw the first stone.
Anyway, I sincerely appreciate the help you provided to a poor sinner. Thanx again.