lib/facter: Encapsulate Facter setcode

Avoid potential problems, and add setcode only if edploy command is
present and executable.
This commit is contained in:
Sebastien Badia 2014-11-18 12:01:03 +01:00
parent 3b7c4fc640
commit fa6dfdf6d5

View File

@ -17,18 +17,24 @@
# #
Facter.add('edeploy_role_version') do Facter.add('edeploy_role_version') do
setcode do setcode do
if File.executable?('/usr/sbin/edeploy')
Facter::Util::Resolution.exec('/usr/sbin/edeploy version') Facter::Util::Resolution.exec('/usr/sbin/edeploy version')
end end
end end
end
Facter.add('edeploy_role_name') do Facter.add('edeploy_role_name') do
setcode do setcode do
if File.executable?('/usr/sbin/edeploy')
Facter::Util::Resolution.exec('/usr/sbin/edeploy role') Facter::Util::Resolution.exec('/usr/sbin/edeploy role')
end end
end end
end
Facter.add('edeploy_profile') do Facter.add('edeploy_profile') do
setcode do setcode do
if File.executable?('/usr/sbin/edeploy')
Facter::Util::Resolution.exec('/usr/sbin/edeploy profile') Facter::Util::Resolution.exec('/usr/sbin/edeploy profile')
end end
end end
end