Not just placing all trust in Puppet. That's the point of this tiny program 
now named 

  yaml2csv.rb

If you revise/improve, you must post back your improved version.

And remember, by ensuring you noop your Puppet cloud and review it first 
before actions,
you will keep the human in the loop before you un-noop and puppet agent -t 
from a far,
rerun on all the YAML's, and see what you did in an actual human-readable 
format.

Imagine that?

The fear, of course, is that some kind of whacko code gets into Puppet (I 
know, open
source and all that), but, frankly, I can't take that chance so verifying 
and proofing 
mass-cloud changers is what I'm into.

Happy Hacking,

Stuart

#!/usr/bin/ruby

require 'puppet'

 

output = ""

 

# Are there args?

if defined?(ARGV)

 

   # First argument needs to be the yaml file

   filename = ARGV.first

 

   # Has to be defined

   if defined?(filename)

 

     # Make a real version we can work on that is not frozen

     fileName = filename.dup

 

     # Get the report object

     report = YAML.load_file(filename)

 

     # Get the base name of the file to the far right

     fileName = File.basename(filename)

 

     # Formulate the timestamp

     dateStamp = fileName.split /\./

 

     # Loop through the logs and print appropriately

     report.logs.each do |logg|

      if logg.line or logg.line == 0 then

        output = sprintf("%s, %s, %s, %s, (line %s), %s, %s, %s",

                 report.host,

                 dateStamp[0],

                 logg.time,

                 logg.file,

                 logg.line,

                 logg.source,

                 logg.level,

                 logg.message

                  )

        searchResult = output.grep(/changed|noop/)

        if searchResult.any? then

          printf("%s\n",output)

        end

      else

        output = sprintf("%s, %s, %s, %s, (line %s), %s, %s, %s",

                 report.host,

                 dateStamp[0],

                 logg.time,

                 logg.file,

                 "none",

                 logg.source,

                 logg.level,

                 logg.message

                  )

        searchResult = output.grep(/changed|noop/)

        if searchResult.any? then

          printf("%s\n",output)

        end

      end

    end

  end

end

# Bless Ygor. Merry Christmas everybody!!!!

On Thursday, December 12, 2013 3:20:41 PM UTC-8, Stuart Cracraft wrote:

>
> Hi everybody,
>
> Is there a command-line program which parses:
>
>   puppetmasters*:/var/lib/puppet/reports/*/*.yaml
>
> into simple a simple (though lengthy) report perhaps with
> column/field/etc. selection based on a straightforward method.
>
> Holler if you know of any. I know this was queried by me
> on this list recently and all sorts of stuff was posted. If
> I don't get it here, I'll need to go over to puppet-developers
> and ask there.
>
> Surely, someone has written something they're proud of and
> will share it forward.
>
> Stuart
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/e5d8be43-cd80-4b79-bf4c-4a52f2c408bb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to