Hello all,
I'm looking to create a custom fact based on the result of a host name
prefix. Some examples of host names are:
home-server-01
work-server-02
I'd like the fact to assign a role to the server based on it's prefix and
I'm having a hard time getting this one to work:
require 'facter'
Facter.add('host_role') do
setcode do
hostname_array = Facter.value(:hostname).split('-')
first_in_array = hostname_array.first
first_in_array.each do |x|
if x =~ /^(home|work)/
role = '"#{x}" server'
else
role = 'other server'
end
role
end
end
Would anybody have an pointers on why this may not be working. I feel
stupid for asking this but my understanding of ruby is quite basic and
google has stopped taking my calls.
Thank you in advance for the help.
Cheers,
Mike
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/b44ea4a2-caeb-45c8-8eee-ec6533485796%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.