Created
March 20, 2018 20:16
-
-
Save natemccurdy/ae5871bcd6b4cd1a372e6c52830f28e6 to your computer and use it in GitHub Desktop.
Custom fact to list all profiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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