On Sep 16, 2008, at 11:18 PM, Luke Kanies wrote:

> Can you be specific on what kinds of errors you're seeing?

That's part of the problem. No errors posted, things just don't work.

Full (if contrived) example:

The plain vanilla Ruby function

------ start /var/lib/puppet/lib/puppet/foo.rb --------
class Foo
  def action
   f = File.open("/tmp/foo_file",'w')
   f.write("bar\n")
   f.close
  end
end
----------------------- end foo.rb -------------------

The custom type append_if_no_such line. Straight out of the puppet  
documentation with the addition of the "require" and a call to the  
"Foo" class inside the "insync" block.

- start /var/lib/puppet/lib/puppet/types/append_if_no_such_line.rb -
require "Foo"
module Puppet
   newtype(:append_if_no_such_line) do
     @doc = "Ensure that the given line is defined in the file, and  
append
             the line to the end of the file if the line isn't already  
in
             the file."

     newparam(:name) do
       desc "The name of the resource"
     end

     newparam(:file) do
       desc "The file to examine (and possibly modify) for the line."
     end

     newparam(:line) do
       desc "The line we're interested in."
     end

     newproperty(:ensure) do
       desc "Whether the resource is in sync or not."

       defaultto :insync

       def retrieve
         File.readlines(resource[:file]).map { |l|
             l.chomp
         }.include?(resource[:line]) ? :insync : :outofsync
       end

       newvalue :outofsync
       newvalue :insync do
        myFoo = new Foo()
        myFoo.action
         File.open(resource[:file], 'a') { |fd| fd.puts  
resource[:line] }
       end
     end
   end
end
--------------------------- end ---------------------------

BTW, I've put the Foo.rb file just about everywhere I can think
of and done every include and require I could think of. I even
wrapped it with "module puppet" and put it everywhere, etc.

Anyhow, with the above files in the places mentioned, I add
the following node to site.pp:

node 'pinocchio.endpoint.com' {
   append_if_no_such_line{ 'test':,
       file => '/tmp/splat',
       line => 'foobar'
   }
}

Then I go to the pinocchio machine and run puppetd:

[EMAIL PROTECTED] ~]# cat /tmp/splat
nope
[EMAIL PROTECTED] ~]# puppetd --test
info: Retrieving plugins
notice: Ignoring cache
info: Caching catalog at /var/lib/puppet/localconfig.yaml
notice: Starting catalog run
notice: Finished catalog run in 0.06 seconds
[EMAIL PROTECTED] ~]# cat /tmp/splat
nope

As you can see. Everything *seems* to be fine, but "foobar" doesn't  
get appended to /tmp/splat nor does the file that Foo is supposed to  
create appear.

Adding --debug I can see that it knows about foo.rb, and so on:

[EMAIL PROTECTED] ~]# puppetd --test --debug
debug: Creating default schedules
debug: Failed to load library 'shadow' for feature 'libshadow'
debug: /Settings[/etc/puppet/puppet.conf]/Settings[ssl]/File[/var/lib/ 
puppet/ssl/public_keys]: Autorequiring File[/var/lib/puppet/ssl]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[ssl]/File[/var/lib/ 
puppet/ssl/csr_pinocchio.endpoint.com.pem]: Autorequiring File[/var/ 
lib/puppet/ssl]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[ssl]/File[/var/lib/ 
puppet/ssl/public_keys/pinocchio.endpoint.com.pem]: Autorequiring  
File[/var/lib/puppet/ssl/public_keys]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[main]/File[/var/lib/ 
puppet/ssl]: Autorequiring File[/var/lib/puppet]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[ssl]/File[/var/lib/ 
puppet/ssl/private]: Autorequiring File[/var/lib/puppet/ssl]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[ssl]/File[/var/lib/ 
puppet/ssl/private_keys/pinocchio.endpoint.com.pem]: Autorequiring  
File[/var/lib/puppet/ssl/private_keys]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[ssl]/File[/var/lib/ 
puppet/ssl/certs]: Autorequiring File[/var/lib/puppet/ssl]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[ssl]/File[/var/lib/ 
puppet/ssl/certs/pinocchio.endpoint.com.pem]: Autorequiring File[/var/ 
lib/puppet/ssl/certs]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[ssl]/File[/var/lib/ 
puppet/ssl/certs/ca.pem]: Autorequiring File[/var/lib/puppet/ssl/certs]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[ssl]/File[/var/lib/ 
puppet/ssl/private_keys]: Autorequiring File[/var/lib/puppet/ssl]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[main]/File[/var/lib/ 
puppet/lib]: Autorequiring File[/var/lib/puppet]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[puppetd]/File[/var/ 
lib/puppet/state/state.yaml]: Autorequiring File[/var/lib/puppet/state]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[puppetd]/File[/var/ 
lib/puppet/classes.txt]: Autorequiring File[/var/lib/puppet]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[puppetd]/File[/etc/ 
puppet/puppet.conf]: Autorequiring File[/etc/puppet]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[main]/File[/var/lib/ 
puppet/state]: Autorequiring File[/var/lib/puppet]
debug: /Settings[/etc/puppet/puppet.conf]/Settings[puppetd]/File[/var/ 
lib/puppet/state/state.yaml]: Changing mode
debug: /Settings[/etc/puppet/puppet.conf]/Settings[puppetd]/File[/var/ 
lib/puppet/state/state.yaml]: 1 change(s)
debug: /Settings[/etc/puppet/puppet.conf]/Settings[puppetd]/File[/var/ 
lib/puppet/state/state.yaml]/mode: mode changed '640' to '660'
debug: Finishing transaction 23456260373300 with 1 changes
debug: Loaded state in 0.01 seconds
debug: Retrieved facts in 0.17 seconds
debug: Puppet::Network::Client::File: defining fileserver.describe
debug: Puppet::Network::Client::File: defining fileserver.list
debug: Puppet::Network::Client::File: defining fileserver.retrieve
info: Retrieving plugins
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib]/checksum: Initializing checksum hash
debug: /File[/var/lib/puppet/lib]: Creating checksum {mtime}Wed Sep 17  
13:29:20 -0400 2008
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/foo.rb]/checksum: Initializing  
checksum hash
debug: /File[/var/lib/puppet/lib/foo.rb]: Creating checksum  
{md5}8ea27953b1d23c7d204c49027108dd00
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/puppet]/checksum: Initializing  
checksum hash
debug: /File[/var/lib/puppet/lib/puppet]: Creating checksum {mtime}Wed  
Sep 17 13:29:19 -0400 2008
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/puppet/provider]/checksum:  
Initializing checksum hash
debug: /File[/var/lib/puppet/lib/puppet/provider]: Creating checksum  
{mtime}Mon Sep 08 14:34:11 -0400 2008
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/puppet/provider/sysctl]/checksum:  
Initializing checksum hash
debug: /File[/var/lib/puppet/lib/puppet/provider/sysctl]: Creating  
checksum {mtime}Mon Sep 08 14:34:11 -0400 2008
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/puppet/provider/sysctl/parsed.rb]/ 
checksum: Initializing checksum hash
debug: /File[/var/lib/puppet/lib/puppet/provider/sysctl/parsed.rb]:  
Creating checksum {md5}9c4a5ecf1e7267fa7c015f769f24bcd9
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/puppet/cell_serv_db.rb]/checksum:  
Initializing checksum hash
debug: /File[/var/lib/puppet/lib/puppet/cell_serv_db.rb]: Creating  
checksum {md5}f86aa848a5819984bf019738a0e73f4a
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/puppet/type]/checksum: Initializing  
checksum hash
debug: /File[/var/lib/puppet/lib/puppet/type]: Creating checksum  
{mtime}Wed Sep 17 13:20:49 -0400 2008
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/puppet/type/openafs.rb]/checksum:  
Initializing checksum hash
debug: /File[/var/lib/puppet/lib/puppet/type/openafs.rb]: Creating  
checksum {md5}0c4cf65347ed35d068ded6d428070d23
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/puppet/type/sysctl.rb]/checksum:  
Initializing checksum hash
debug: /File[/var/lib/puppet/lib/puppet/type/sysctl.rb]: Creating  
checksum {md5}65fe3deaf4e245b7a5f031dac3d73f4d
debug: Calling fileserver.describe
debug: Calling fileserver.list
debug: /File[/var/lib/puppet/lib/puppet/type/ 
append_if_no_such_line.rb]/checksum: Initializing checksum hash
debug: /File[/var/lib/puppet/lib/puppet/type/ 
append_if_no_such_line.rb]: Creating checksum  
{md5}cd2e790d8c0ee23589fb2e1deb092870
debug: Calling fileserver.describe
debug: Finishing transaction 23456251100620 with 0 changes
notice: Ignoring cache
debug: Retrieving catalog
debug: Calling puppetmaster.getconfig
debug: Retrieved catalog in 0.15 seconds
debug: Creating default schedules
info: Caching catalog at /var/lib/puppet/localconfig.yaml
notice: Starting catalog run
debug: Loaded state in 0.01 seconds
debug: Finishing transaction 23456271173100 with 0 changes
debug: Storing state
debug: Stored state in 0.05 seconds
notice: Finished catalog run in 0.06 seconds


-- 
Steve McIntosh
End Point Corporation
http://www.endpoint.com






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to