Skip to content

Instantly share code, notes, and snippets.

@binford2k
Created March 24, 2021 19:45
Show Gist options
  • Save binford2k/59cef785b6ee891a25071884b9bd4117 to your computer and use it in GitHub Desktop.
Save binford2k/59cef785b6ee891a25071884b9bd4117 to your computer and use it in GitHub Desktop.
simple fact to report stats from last puppet run as a fact
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
@binford2k
Copy link
Author

The actual changes are probably not a good idea to keep. They might be REALLY huge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment