Created
October 30, 2010 10:06
Revisions
-
jordansissel revised this gist
Oct 30, 2010 . 2 changed files with 22 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ #!/usr/bin/env ruby # @@ -27,6 +26,22 @@ [ "/var/log/apache2/access.log" ]: tags => ["apache-access"]; } # even custom defines work. define fancypants() { input { "/tmp/$name": tags => ["fancypants"]; "/tmp/$name.1": tags => ["fancypants"]; "/tmp/$name.2": tags => ["fancypants"]; } } fancypants { "hello": ; } EOF # Now compile a catalog from our code. 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,8 @@ % ruby puppet-parser-elsewhere.rb Found resource 'Input[/tmp/hello.2]' with tags: "fancypants" Found resource 'Input[/var/log/auth.log]' with tags: "linux-syslog" Found resource 'Input[/tmp/hello.1]' with tags: "fancypants" Found resource 'Input[/tmp/hello]' with tags: "fancypants" Found resource 'Fancypants[hello]' with tags: nil Found resource 'Input[/var/log/apache2/access.log]' with tags: "apache-access" Found resource 'Input[/var/log/messages]' with tags: "linux-syslog" -
jordansissel created this gist
Oct 30, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #!/usr/bin/env ruby # require "rubygems" require "puppet" # gem puppet require "ap" # gem awesome_print # Need to define a type for each type we want to have. # Otherwise, unknown types are errors in puppet. Puppet::Type.newtype(:input) do newproperty(:name) do desc "Input URL" end # property :name newproperty(:tags) do desc "Tags for an input" end # property 'tags' end # type 'input' # This is where we put the puppet manifest code. You could just use a file # here, but I'm inlining it for easy reading. Puppet[:code] = <<EOF input { [ "/var/log/messages", "/var/log/auth.log" ]: tags => ["linux-syslog"]; [ "/var/log/apache2/access.log" ]: tags => ["apache-access"]; } EOF # Now compile a catalog from our code. node = Puppet::Node.find("default") catalog = Puppet::Resource::Catalog.find("default", :use_node => node) # Each vertex is a resource. catalog.vertices.each do |resource| next if ["Class", "Stage"].include?(resource.type ) puts "Found resource '#{resource.to_s}' with tags: #{resource[:tags].inspect}" end 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ % ruby puppet-parser-elsewhere.rb Found resource 'Input[/var/log/apache2/access.log]' with tags: "apache-access" Found resource 'Input[/var/log/messages]' with tags: "linux-syslog" Found resource 'Input[/var/log/auth.log]' with tags: "linux-syslog"