On Nov 11, 2008, at 9:48 AM, Nigel Kersten wrote: > > So I'm working on changing the directoryservice provider for users so > that it doesn't use clear text passwords, but instead takes a hash. > > Mac OS X stores password hashes in separate files per user, so I was > thinking rather than repeating code Puppet already does, that it would > make sense to instantiate a File resource for the password hash file > for that user. > > I'm having trouble working out exactly how to do this. > > This sort of code seems to create the right kind of object... > > require 'puppet' > require 'puppet/type/file' > > myfile = Puppet::Type.newfile :path => "/tmp/spam", > :ensure => :file, > :backup => false, > :content => "eggs" > > > but I'm unsure how to best bring this resource actually into sync... > the write method for the file type looks promising, but requires > specifying the content again, which makes me think this is the wrong > path to take. > > Do I really need to create a stub catalog and a transaction by > applying the catalog? Is there some better way I should be doing this?
As Andrew indicates, resources can generate other resources, either before or during the transaction (use 'generate' for pre-transaction and 'eval_generate' for mid-transaction). There aren't a lot of examples of this right now (maillist uses generate, files use eval_generate), but it's pretty simple and getting simpler. Basically, you just create the resources and return them from the method. The big difference between the two methods is that pre-transaction generated resources get sorted using relationships like any other resource, but mid-transaction resources are too late for that. Thus, the mid-transaction resources just proxy all of their events through their generating resource, but the pre-transaction resources can have normal relationships. For your purposes, you might as well use 'generate', but it doesn't look like it matters. I'd make sure you set 'ensure' correctly, though. -- Real freedom lies in wildness, not in civilization. -- Charles Lindbergh --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---