To install this module on your puppet master
mkdir -p /etc/puppet/modules/hostint/lib/facterCopy the following code and place it in the file "/etc/puppet/modules/hostint/lib/facter/hostint.rb"
require 'facter' Facter.add(:hostint) do confine :kernel => %w{FreeBSD} setcode do Facter::Util::Resolution.exec("netstat -f inet -rn | awk '$1==\"default\" { print $6 }'") end end Facter.add(:hostint) do confine :kernel => %w{Linux} setcode do Facter::Util::Resolution.exec("netstat -rn | awk '$1==\"0.0.0.0\" { print $8 }'") end endEnsure you have pluginsync enabled in your nodes puppet.conf
pluginsync = trueNow you are free to use this fact name in any module/manifest
<%= hostint %>You can also download the module on the puppet forge http://forge.puppetlabs.com/panaman/hostint/0.0.1
Or install it straight from your puppet master
puppet module install panaman-hostint
No comments:
Post a Comment