Created
March 24, 2021 19:45
-
-
Save binford2k/59cef785b6ee891a25071884b9bd4117 to your computer and use it in GitHub Desktop.
simple fact to report stats from last puppet run as a fact
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(:puppet_report) do | |
setcode do | |
report = YAML.load_file(Puppet.settings['lastrunreport']) | |
all_changes = report.resource_statuses.select { |title, rsc| rsc.changed } | |
config_changes = all_changes.select { |title, rsc| rsc.resource_type != 'Notify' } | |
{ | |
:time => report.time, | |
:configuration_version => report.configuration_version, | |
:status => report.status, | |
:success => (['changed', 'unchanged'].include? report.status), | |
:noop => report.noop, | |
:environment => report.environment, | |
:changes => all_changes.map { |title, rsc| title }, | |
:change_count => all_changes.count, | |
:config_changes => config_changes.map { |title, rsc| title }, | |
:config_change_count => config_changes.count, | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The actual changes are probably not a good idea to keep. They might be REALLY huge.