Puppet Version: 4.10.12 Puppet Server Version: 2.8.1 OS Name/Version: CentOS Linux release 7.6.1810 I have weird behavior which occurs randomly where Puppet::Type.type('yumrepo') reports that a yum repo is enabled despite it is not. I'm using this fact
require 'puppet'def to_boolean(value) |
%w[absent yes true 1].include?(value.downcase) |
endFacter.add('enabled_repos') do |
setcode do |
repos = [] |
Puppet::Type.type('yumrepo').instances.find_all do |repo| |
repo_value = repo.retrieve |
repos << repo.name if to_boolean(repo_value[repo.property(:enabled)].to_s.strip) |
end |
repos.sort |
end |
end |
I have a repo defined with enbled=0, ex: myrepo I run this loop to reproduce:
( date; while :; do facter -p enabled_repos | grep -i myrepo && date && break; sleep 1; done ; yum repolist ) >enabled-repo.tmp 2>&1 & |
After few days I get:
Mon Sep 2 03:48:12 UTC 2019 |
"myrepo", |
Thu Sep 5 16:09:28 UTC 2019 |
Loaded plugins: enabled_repos_upload, fastestmirror, langpacks, package_upload, product-id, search- |
: disabled-repos, subscription-manager, tracer_upload, versionlock |
Loading mirror speeds from cached hostfile |
repo id repo name status |
!Centos_Centos_7_Base Centos_7 Base 10,019 |
!Centos_Centos_7_Extras Centos 7 Extras 435 |
!Centos_Centos_7_Opstools Centos 7 Opstools 896 |
!Centos_Centos_7_Updates Centos 7 Updates 4,067 |
!Centos_Centos_7_kvm-common Centos 7 kvm-common 79 |
!Centos_Centos_7_ovirt Centos 7 ovirt 744 |
!Centos_Centos_sclo Centos sclo 786 |
!Centos_Centos_sclo-rh Centos sclo-rh 8,444 |
repolist: 25,470 |
Uploading Enabled Repositories Report |
Loaded plugins: fastestmirror, langpacks, product-id, subscription-manager, |
: versionlock
|
myrepo is included in the fact enabled_repos but it is not enabled on the system. Desired Behavior: myrepo is not included in the fact enabled_repos. Only repos with enable=1 should be included. Actual Behavior: myrepo is included in the fact enabled_repos but it is not enabled on the system. |