Skip to content

Instantly share code, notes, and snippets.

@DamianZaremba
Created May 6, 2014 11:02
Show Gist options
  • Save DamianZaremba/bf875e55a297a9c10a51 to your computer and use it in GitHub Desktop.
Save DamianZaremba/bf875e55a297a9c10a51 to your computer and use it in GitHub Desktop.
Broken facter plugin
# This is a horrible thing
# Kinda (mostly) figures out the server type from the hostname
Facter.add("servertype") do
setcode do
hostname = Facter.value('hostname')
if hostname.include?('-')
hostname_parts = hostname.split("-", 0)
hostname_parts[0].downcase
elsif hostname =~ /^ns/
"ns"
else
"other"
end
end
end
#### Throws:
# Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, Error from DataBinding 'hiera' while looking up 'rsyslog::modules': undefined method `empty?' for nil:NilClass at /etc/puppet/environments/production/modules/rc/manifests/base.pp:2:1 on node puppet-04.*******************
# Warning: Not using cache on failed catalog
# Error: Could not retrieve catalog; skipping run
# This is a horrible thing
# Kinda (mostly) figures out the server type from the hostname
Facter.add("servertype") do
setcode do
hostname = Facter.value('hostname')
if hostname.include?('-')
hostname_parts = hostname.split("-", 0)
hostname_parts[0].upcase
elsif hostname =~ /^ns/
"ns"
else
"other"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment