-
-
Save raphink/7133992 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# crm_support: true/nil | |
# Whether there is Pacemaker installed | |
Facter.add('crm_support') do | |
confine :kernel => :linux | |
setcode do | |
not Facter::Util::Resolution.exec('which crm_resource').empty? | |
end | |
end | |
crm_resources = [] | |
Facter.add('crm_raw_resources') do | |
confine :crm_support => true | |
# Put everything in a setcode block for refresh purposes | |
setcode do | |
resources = Facter::Util::Resolution.exec('crm_resource -l') | |
if resources.empty? | |
0 | |
else | |
crm_resources = resources.split | |
crm_resources.join(',') | |
end | |
end | |
end | |
crm_resources.each do |resource| | |
if resource =~ /^\w+:(0|1)$/ # Master/Slave resources | |
_resource = resource.split(':')[0] | |
if crm_output =~ /^.*\sMaster$/ | |
fact_name = "crm_#{_resource}_master" | |
else | |
fact_name = "crm_#{_resource}_slave" | |
end | |
else | |
fact_name = "crm_#{resource}" | |
end | |
command = "crm_resource --resource #{resource} --locate" | |
Facter.add(fact_name) do | |
setcode do | |
crm_output = Facter::Util::Resolution.exec(command) | |
/^resource #{resource} is running on: (.+?)\s?\w*$/.match(crm_output)[1] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment