Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Created March 20, 2018 20:16
Show Gist options
  • Save natemccurdy/ae5871bcd6b4cd1a372e6c52830f28e6 to your computer and use it in GitHub Desktop.
Save natemccurdy/ae5871bcd6b4cd1a372e6c52830f28e6 to your computer and use it in GitHub Desktop.
Custom fact to list all profiles
Facter.add(:profiles) do
setcode do
require 'puppet'
# Use the [agent] context because some agents have
# classfile overridden in puppet.conf
Puppet.settings.preferred_run_mode = :agent
classfile = Puppet['classfile']
profiles = []
File.readlines(classfile).select do |line|
next unless line =~ /^profile::/
profiles << line.strip.chomp
end
profiles.uniq.sort
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment