Greg
10/31/2024, 12:38 PMFutureSea Dev
10/31/2024, 1:17 PMDavid Sandilands
10/31/2024, 3:52 PMLumiere
10/31/2024, 3:57 PM$yamlcontent = versioncmp($facts['puppetversion'], '8.0.0') ? {
1 => stdlib::to_yaml($subscription_state, { indentation => 2 }),
default => to_yaml($subscription_state, { indentation => 2 }),
}
Lumiere
10/31/2024, 3:57 PMbastelfreak
10/31/2024, 3:58 PMbastelfreak
10/31/2024, 3:58 PMCVQuesty
10/31/2024, 3:59 PMbastelfreak
10/31/2024, 3:59 PMLumiere
10/31/2024, 4:07 PMLumiere
10/31/2024, 4:07 PMDavid Sandilands
10/31/2024, 4:29 PMIlovPuppet
10/31/2024, 5:19 PMLumiere
10/31/2024, 6:34 PMLumiere
10/31/2024, 6:35 PMDr Bunsen Honeydew
10/31/2024, 8:45 PMThomas Lau
11/01/2024, 6:35 AMcanihavethisone
11/01/2024, 9:04 AMexec 'change master':
command => 'puppet config set master <new master> && rm -rf /etc/puppetlabs/puppet/ssl && echo "done" > /root/puppet_master_changed_certs_purged.txt && shutdown',
creates => '/root/puppet_master_changed_certs_purged.txt',
}
matt
11/01/2024, 10:41 AMmatt
11/01/2024, 10:41 AMOleksandr Bilko
11/01/2024, 3:11 PMrequire 'facter'
# Detect Broadcom/LSI RAID
Facter.add(:has_broadcom) do
confine kernel: 'Linux'
ENV["PATH"] = "/bin:/sbin:/usr/bin:/usr/sbin"
setcode do
if Facter::Util::Resolution.which('lspci') && Facter::Util::Resolution.which('grep')
Facter::Util::Resolution.exec("lspci | grep -i 'raid' | grep -iqE 'Broadcom|LSI|MegaRaid'") != nil
else
false
end
end
end
Here is the output `facter -p`:
# facter -p | grep 'has_broadcom'
[2024-11-01 15:04:08.536918 ] ERROR Facter - Could not load puppet gem, got cannot load such file -- puppet
Here is the output `puppet facts`:
# puppet facts | grep 'has_broadcom'
"has_broadcom": true,
vchepkov
11/01/2024, 3:27 PMFacter.add(:has_broadcom) do
confine :kernel => "Linux"
setcode do
Facter::Core::Execution.execute("lspci | grep -iqE 'Broadcom|LSI|MegaRaid' | grep -i RAID").to_s != ''
end
end
bastelfreak
11/01/2024, 3:28 PMDavit Gurgenidze
11/02/2024, 5:33 PMJohn Warburton
11/04/2024, 4:26 AMthere must not be any code outsideWhat does "any" mean in this case? Can I wrap myandsetcode
blocksconfine
Facter.add
in a loop like:
Facter.value('networking')['interfaces'].each do |i, val|
Facter.add("myfact_#{i}") do
setcode do
"value_for_#{i}"
end
end
end
Technically this works, but is that each
loop "any code outside `setcode`"? And yes, I am aware a structured fact is the real answer. I would use an external fact if I could but I need to reference the networking
fact
I arrived here due to a lot of legacy facter
code with a lot of code outside setcode
which has just started manifesting in indeterminate fact values, and is fixed by shoving code inside the `setcode`s. I can reduce the amount of change by getting the top level facts in order before changing these facts to structured facts.
Comments and opinions gratefully accepted
Thanks
JohnSlackbot
11/04/2024, 2:00 PMStephen
11/04/2024, 2:05 PMbastelfreak
11/04/2024, 2:07 PMStephen
11/04/2024, 2:09 PMStephen
11/04/2024, 2:10 PM