Skip to content

Instantly share code, notes, and snippets.

@glarizza
Last active April 25, 2016 18:21
Show Gist options
  • Save glarizza/1416a84e4cc79c3329d317da774c312c to your computer and use it in GitHub Desktop.
Save glarizza/1416a84e4cc79c3329d317da774c312c to your computer and use it in GitHub Desktop.
dell_region = case real_domain
when /^(aus).dell.com/
'AMER'
when /^(lon).dell.com/
'EMEA'
else
'UNKNOWN'
end
Facter.add('dell_location') do
confine :kernel => :linux
setcode do
## Logic to pull from dell.cfg
end
end
Facter.add('dell_location') do
confine :kernel => :windows
setcode do
## Logic to pull from Registry
end
end
Facter.add('dell_combined') do
case Facter.value(:kernel)
when 'Linux'
# Do Linux logic here
some_var = do_linux_lookup('foo')
when 'windows'
# Do Windows logic here
some_var = do_windows_lookup('foo')
end
setcode do
# Use the variable above and set the fact
end
end
Facter.add('dell_region') do
confine :kernel => :linux
setcode do
# Get location from Fact
location = Facter.value(:location)
# Now do things...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment