Closed TJM closed 5 years ago
OK, so upon further investigation, its the resources { 'yumrepo': purge => true }
that is causing the error:
[root@linux01 ~]# puppet apply -e 'resources { "yumrepo": purge => true }'
Notice: Compiled catalog for linux01.vagrant.local in environment vagrant in 0.10 seconds
Error: /Stage[main]/Main/Resources[yumrepo]: Failed to generate additional resources using 'generate': Section "cr" is already defined, cannot redefine (file: /etc/yum.repos.d/CentOS-CR.repo)
Notice: Applied catalog in 0.08 seconds
However, I wonder why none of the others (base, updates, etc) caused this error too? Why CR? anyone?
I need more information about how you added the CR repository. It might collide with the files from data/
.
FYI: I explained in issue #94 how to remove repositories.
Steps to reproduce...
rm -rf /etc/yum.repos.d/*
)
puppet apply -e 'include yum'
?)yum upgrade -y
)resources { yumrepo: purge => true }
in your puppet code, it will give an error similar to the one above (maybe not specifically "cr")So, I think based on everything else I have seen, the actual problem is the "yumrepo" type/provider. This module could workaround this issue using file resource backing and build the purge option in, rather than depending on the resources { yumrepo: purge => true }
.
Alternatively, the "cause" of this problem, which is an environment specific packer build script that removes all files from /etc/yum.repos.d, could be adjusted to truncate the file instead of removing it, which, since it is a "config" file in the repo, would not be overwritten.
I am going to close this one.
Thanks, Tommy
One other note, as of Puppet 6, the yumrepo resource type finally has a "target" parameter (that doesn't say not to use it) .. so the target could be set to the "expected" filename from the OS packages:
$ rpm -qV centos-release
missing c /etc/yum.repos.d/CentOS-Base.repo
missing c /etc/yum.repos.d/CentOS-CR.repo
missing c /etc/yum.repos.d/CentOS-Debuginfo.repo
missing c /etc/yum.repos.d/CentOS-Media.repo
missing c /etc/yum.repos.d/CentOS-Sources.repo
missing c /etc/yum.repos.d/CentOS-Vault.repo
missing c /etc/yum.repos.d/CentOS-fasttrack.repo
If anyone else is being bit by this, instead of deleting the files in /etc/yum.repos.d, truncate them (make them empty). As they are "config" files, they will not be replaced during upgrades unless they are missing.
for file in /etc/yum.repos.d/CentOS-*; do cat /dev/null > $file; done
... then you can continue to use any "custom" files you have created. :)
~tommy
Affected Puppet, Ruby, OS and module versions/distributions
How to reproduce (e.g Puppet code you use)
NOTE: $rpm_gpg_keys=>(epel gpg key) until PR96 is in :)
What are you seeing
After doing
yum upgrade
from 7.3 -> 7.4, the centos-release package automatically created the "default' /etc/yum.repos.d files. (specifically /etc/yum.repos.d/CentOS-*.repo)The following error comes up during a puppet run:
What behaviour did you expect instead
Shouldn't the
resources { 'yumrepo': purge => true }
take care of removing that duplicate?Output log
See Error above
Any additional information you'd like to impart
Asked this question in Puppet Community Slack too, I think it may be a "puppet" bug, but I am considering that we should maybe try to create the "default" OS files as the same filenames as they would be created by the -release package, so that they are not duplicated? (if that is possible even)
They are listed as "config" files, so they would not be overwritten during upgrade.
~tommy