You want to remove a config option from a yum repository config file.
class remove_yum_config {
yumrepo { 'my_repo':
gpgcheck => 'absent',
}
}
There are a few quirks to managing yumrepo
resources worth keeping in
mind and the first that most people hit is how to remove a setting from
a configuration file. The Yumrepo
provider only manages the settings
that you explicitly specify. Any other settings present are preserved
and left untouched by Puppet. Below is an example of this in action:
# create the repo config with two options specified.
$ cat yum-repo.pp
# ... snip ...
yumrepo { 'company_app_repo':
enabled => 1,
gpgcheck => 1,
}
#... snip ...
# Once we run puppet both options are present in the file.
$ cat /etc/yum.repos.d/company_app_repo.repo
[company_app_repo]
enabled=1
gpgcheck=1
# now we remove 'gpgcheck' from the puppet
# manifest and rerun puppet
cat yum-repo.pp
# ... snip ...
yumrepo { 'company_app_repo':
enabled => 1,
}
#... snip ...
# and... gpgcheck is still present, and now unmanaged.
cat /etc/yum.repos.d/company_app_repo.repo
[company_app_repo]
enabled=1
gpgcheck=1
# to remove the key and value we set gpgcheck to 'absent'
cat yum-repo.pp
# ... snip ...
yumrepo { 'company_app_repo':
enabled => 1,
gpgcheck => 'absent',
}
#... snip ...
# and now it's gone from the config
cat /etc/yum.repos.d/company_app_repo.repo
[company_app_repo]
enabled=1