Thank you Rob.  I have it working using slice and some new variables.

Here are my final scripts.  

Facter.add(:server_role) do
  setcode do
    ip_address = Facter.value(:ipaddress).tr('.', '')
    ip_address = ip_address.to_i
    host = Facter.value(:hostname)
    if host[0,1] != "a"
      server_role = 'workstation'
    else
      if ip_address.between?(1921680160, 1921680170)
        server_role = host.slice(0,2)
      else
        server_role = host.slice(0.4)
      end
    end
  end
end

Facter.add(:location_code) do
  setcode do
    address = Facter.value(:ipaddress).tr('.', '')
    address = address.to_i
    host = Facter.value(:hostname)
    if host[0,1] != "a"
      net = Facter.value(:network)
      net = net[0..-3] += '.30'
      net = Facter::Core::Execution.exec("nslookup #{net} | grep name | awk 
'{print $4}'")
      net = net.partition('.').first
      net = net[0..3]
    else
      if address.between?(1921680160, 1921680170)
        location_code = host.slice(0,2)
      else
        location_code = host.slice(0,4)
      end
    end
  end
end





-- 
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/e0a376db-83c9-4366-9ddd-318e6e298b36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to