用于查看 Puppet 代理所做的最后更改的日志文件

Log file to view last changes made by puppet agent

如果您在代理程序在后台运行时执行 puppet agent -t 日志文件在哪里 我们可以在其中看到更改,而不是在 puppet 仪表板上。

我查看了 puppet.conf 并且在主要部分中我看到了 logdir,但是没有在该位置创建日志文件。

在Linux中,查看系统日志(/var/log/messagesjournalctl)。 您应该在 /var/lib/puppet

中以 .yaml 格式获得每次执行的报告

来自文档:

When running as a service, Puppet agent logs messages to syslog. Your syslog configuration dictates where these messages will be saved, but the default location is /var/log/messages on Linux, /var/log/system.log on Mac OS X, and /var/adm/messages on Solaris.

When started with the --logdest FILE option, Puppet agent logs to the file specified by FILE.

https://docs.puppet.com/puppet/4.8/services_agent_unix.html#running-puppet-agent-as-a-service

正如 Raul 提到的,最后一个 运行 报告被保存为 statedir 目录下的 yaml 文件。

根据您的 OS 和您使用的 Puppet 版本,这可能位于不同的位置。

例如,在我安装了 Puppet 4 的服务器上:

$ tree $(puppet agent --configprint statedir)
/opt/puppetlabs/puppet/cache/state
├── classes.txt
├── graphs
│   ├── expanded_relationships.dot
│   ├── relationships.dot
│   └── resources.dot
├── last_run_report.yaml
├── last_run_summary.yaml
├── resources.txt
├── state.yaml
└── transactionstore.yaml

1 directory, 9 files

阅读最后一份报告文件的好工具是 report-print。如果您需要上一份报告中的特定信息,您可以调整一些报告打印代码来制作您自己的报告打印机。

您还可以使用所谓的报表处理器,即当您编写自定义代码来控制格式和处理数据时,例如发布到 Splunk 服务器、Slack、Hipchat 等。一个简单的例子是 store_json,它将报告存储为 JSON 而不是 Yaml。

这是一个较旧的问题,但已接受的答案对我没有帮助,所以这是其他人可能会觉得有用的替代方法。如果您的人偶 运行s 发生在不久前,那么它的输出可能不会出现在 /var/log/messages.

相反,您可以在 /var/lib/puppet/state/last_run_summary.yaml(和 last_run_report.yaml)的节点上查看最后一个人偶 运行 的摘要(和报告)。报告是之前 运行 的完整日志,而摘要是简要概述。他们拥有您可能无法从 messages.

获得的信息

Windows Puppets 日志文件路径:C:\ProgramData\PuppetLabs\puppet\cache\state

在这里您会找到一些文件,我发现其中最有用的是: last_run_report.yaml 和 last_run_summary.yaml

截至目前,此路径对 Puppet 6.18 版本有效^