puppet agent --verbose shows a verbose output of the changes done by puppet, such as:
notice: /Stage[main]/Logstash::Config/Logstash::Configdir[agent]/File[/etc/logstash/agent/config]/owner: owner changed 'root' to 'logstash'
notice: /Stage[main]/Varnish/Service[varnish]/ensure: ensure changed 'stopped' to 'running'
I'd need to make some analysis about these changes, but it is not trivial to correctly parse this output.
is there an option to get an structured version of this output (such as in xml or yaml)?
so that I can make queries such as:
- list all the files that have changed
- list all the services that changed from stopped to running.
...
yes, i can use sed and the like as a temporal workaround, but I'd need to have a robust approach.
option1: maybe there is a tool that correctly parses this output?
option2: or maybe there is a "puppet agent" equivalent command that directly produces a structured output?
otherwise, how much time would it required to implement option2 (i am a software developer, and a puppet-user (not currently a puppet-developer)?
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/cHpZlKkPmr4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/1253465309.4764508.1385567092577.JavaMail.root%40sz0126a.westchester.pa.mail.comcast.net.
On Friday, December 13, 2013 5:30:19 AM UTC-8, David Portabella wrote:
The report is focused on describing the changes that occurred during that run. To that end, only the title is included as that information is sufficient to uniquely identify the reporting resource when combined with resource_type. Information concerning properties that were not changed during the run is omitted as this data can be obtained from the catalog that the agent was processing.
In this specific situation, you can modify your file resource such that the path is used as the title:
$dir = '/tmp'
file { "$dir/myfile.txt":
content => 'hello'
}
However, the general problem of matching changes to resources can be solved by loading the report and then loading the catalog and joining the two datasets using the resource_type and title. However, this particular task is one of the problems PuppetDB was designed to solve. PuppetDB stores both the catalogs and reports and provides an API that can be used to query the data.
For example, the changes related to myfile
can be retrieved by querying the events endpoint of the PuppetDB API:
curl -G 'http://localhost:8080/v3/events' --data-urlencode query=\
'["and", ["=", "resource-type", "File"],
["=", "containing-class", "Testfile"],
["=", "certname", "pe-310-agent.puppetdebug.vlan"]]'
Which gives results similar to the following:
[ {
"status" : "success",
"timestamp" : "2013-12-13T17:11:39.144Z",
"certname" : "pe-310-agent.puppetdebug.vlan",
"containing-class" : "Testfile",
"containment-path" : [ "Stage[main]", "Testfile", "File[myfile]" ],
"report" : "6bed5163b50b5857921b5ec27d9147b428c684f8",
"run-start-time" : "2013-12-13T17:11:29.382Z",
"resource-title" : "myfile",
"configuration-version" : "1386954691",
"run-end-time" : "2013-12-13T17:11:36.527Z",
"property" : "ensure",
"message" : "defined content as '{md5}5d41402abc4b2a76b9719d911017c592'",
"new-value" : "file",
"old-value" : "absent",
"line" : 44,
"file" : "/etc/puppetlabs/puppet/modules/testfile/manifests/init.pp",
"report-receive-time" : "2013-12-13T17:11:41.334Z",
"resource-type" : "File"
} ]
The resource contained in the catalog delivered to that node, which contains properties such as the path, can be retrieved by passing the resource Type and title to the resources endpoint:
curl -G 'http://localhost:8080/v3/resources/File/myfile' --data-urlencode 'query=["=", "certname", "pe-310-agent.puppetdebug.vlan"]'
This returns all the parameters of interest:
[ {
"parameters" : {
"path" : "/tmp/myfile.txt",
"mode" : "0755",
"content" : "hello",
"backup" : "main",
"alias" : [ "/tmp/myfile.txt" ]
},
"line" : 45,
"file" : "/etc/puppetlabs/puppet/modules/testfile/manifests/init.pp",
"exported" : false,
"tags" : [ "default", "node", "myfile", "testfile", "class", "file" ],
"title" : "myfile",
"type" : "File",
"resource" : "93f90701c8f54a485246a9e3725040f1992fd90b",
"certname" : "pe-310-agent.puppetdebug.vlan"
} ]
The power of PuppetDB in this situation is that your reporting script can now focus on analyzing the data instead of finding and then filtering it.
Hope this helps!
On Friday, December 13, 2013 2:43:41 PM UTC-8, David Portabella wrote:
is there a way to get the list of resources created when using a puppet apply (instead of puppet agent)?the point is that we need this when refactoring puppet modules, in order to test the modules in a vagrant machine and check that there are not regression issues.so, i run our current puppet modules in a vagrant machine, get the list of all puppet resources created,then i refactor the puppet modules, i run again the refactored puppet modules in a new vagrant machine,and i compare all the files and other resources.
If you are looking to keep track of resources while refactoring, then there are a few approaches you can take:
puppet apply
submits the catalog and reports to PuppetDB: https://docs.puppetlabs.com/puppetdb/1.5/connect_puppet_apply.htmlpuppet apply
in /etc/puppet/routes.yaml
:
---
apply:
catalog:
cache: yaml
This will cause puppet apply
to save a copy of the last compiled catalog to /var/lib/puppet/state/client_yaml/catalog/<certname>.yaml
. The information in this file can be combined with the report in /var/lib/puppet/state/last_run_report.yaml
to create a list of applied resources along with their properties and resulting changes.
The first two approaches will cut down on the amount of custom code you need to write as the task of parsing and storing the reports and catalogs is handled by PuppetDB or the dashboard. Approach 3 works as well and offers a lot of control, but you will need to write a bit of code that extracts data from the catalog and report files before you can focus on the analysis.
# the domain.py used by the wlst
file { "domain.py ${domain_name} ${title}":
path => "${download_dir}/domain_${domain_name}.py",
...
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/6d2793ce-0b9f-468b-bc35-76b149f31f46%40googlegroups.com.
It's too expensive given our small company.
On Wednesday, December 18, 2013 11:25:31 AM UTC-8, Ygor wrote:
�Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.�
Bill Waterson (Calvin & Hobbes)
From: "Stuart Cracraft" <smcra...@me.com>
To: puppet...@googlegroups.com
Sent: Wednesday, December 18, 2013 1:01:42 PM
Subject: Re: [Puppet Users] get a *structured* version of the puppet agent output
thanks.
who is your contact?
I am not getting the help I need.
> On Dec 18, 2013, at 10:00 AM, Jason Slagle <rais...@tacorp.net> wrote:
>
> Hi Stuart,
>
> Puppet Labs has a large professional service department that you might want to engage with these very specific requests. �I'm sure they can give you a hand with whatever you need done.
>
> Jason
>
>> On 12/18/2013 12:55 PM, Stuart Cracraft wrote:
>> What we are looking for is a Ruby program which takes the contents of
>>
>> � /var/lib/puppet/reports/*/*.yaml
>>
>> and reports in detail on everything changed or proposed for change if in
>> noop mode
>> (file permissions, modes, user creates, etc.)
>>
>> Stuart
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/cHpZlKkPmr4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/52B1E2AB.7060909%40tacorp.net.
> For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/36C6B660-92B8-4056-B82D-789C1B0AE7ED%40me.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/65902161-3831-4b46-8828-d80f2f3355f1%40googlegroups.com.