Skip to content

Instantly share code, notes, and snippets.

@rockpapergoat
Created July 24, 2015 16:14
Show Gist options
  • Save rockpapergoat/20956d210060491a495e to your computer and use it in GitHub Desktop.
Save rockpapergoat/20956d210060491a495e to your computer and use it in GitHub Desktop.
begin
Facter.puppet_classes
rescue
Facter.loadfacts()
end
Facter.add("hostname_base") do
setcode do
Facter.value("hostname").gsub(/\d+$/, "")
end
end
if Facter.value("puppet_classes").nil?
#done
else
hostname = Facter.value("hostname")
puppet_classes = Facter.value("puppet_classes")
access = {"access" => ["profiles::access", "profiles::node_type::access", "profiles::access::rclogin"]}
def parse_classes(type,classes)
res = "#{type.values.any? { |klass| classes.include?(klass)} ? 'true' : 'false'}"
return res
end
#puts parse_classes(access,puppet_classes)
Facter.add("access_node") do
setcode do
access_node = parse_classes(access,puppet_classes)
end
access_node
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment