Hello all, We are in the middle of converting our nodes to LDAP. One question that I am having that I have not been able to find anywhere is how does one instantiate a define in an LDAP node. That is, suppose that I have the following class: class definetest { define optfile(fname) { file { /opt/$fname: content => $fname; } exec { CopyOptFile: command => "/bin/cp /opt/$fname /opt/${fname}1"; } } } What would be the LDAP equivalent of the following AST configuration: node "test" { definetest::optfile { "file1": fname => "foo"; "file2": fname => "bar"; } } (Yes, I know that this example is somewhat contrived, but I hope that it conveys the idea. ;-) Many thanks in advance. John Guthrie jguthrie@limewire.com -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Jul 23, 2010, at 3:04 PM, John T. Guthrie wrote:> What would be the LDAP equivalent of the following AST configuration: > > node "test" { > definetest::optfile { > "file1": > fname => "foo"; > "file2": > fname => "bar"; > } > }So you want to list individual files to be copied around in LDAP somehow? If so, I think you probably want to store the list of files using the `puppetVar` attribute. I haven’t used it, but I imagine that’s the place for machine-specific data. Really though, it sounds like you need to generalize things. In most cases, Puppet should know what to do based on the class(es) a system belongs to and not it’s hostname. There are always exceptions of course. There are cases where I want Puppet to distribute a file to the same path with different contents. What I usually do there is use the hostname in the filename on the Puppetmaster (which has no bearing on the client). For example: file { "replicationconf": name => "/etc/openldap/replication.conf", ensure => file, owner => "root", group => "ldap", mode => "640", source => "puppet://puppet/files/$environment/ldap/$hostname.replication", notify => Service["ldap”], } Although, now that I think about it, the per-host changes in that example are so minimal, I should probably look into using `puppetVar` and a template for this file. -- Rob McBroom <http://www.skurfer.com/> -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/23/2010 03:26 PM, Rob McBroom wrote:> On Jul 23, 2010, at 3:04 PM, John T. Guthrie wrote: > > >> What would be the LDAP equivalent of the following AST configuration: >> >> node "test" { >> definetest::optfile { >> "file1": >> fname => "foo"; >> "file2": >> fname => "bar"; >> } >> } >> > So you want to list individual files to be copied around in LDAP somehow? If so, I think you probably want to store the list of files using the `puppetVar` attribute. I haven’t used it, but I imagine that’s the place for machine-specific data. > > Really though, it sounds like you need to generalize things. In most cases, Puppet should know what to do based on the class(es) a system belongs to and not it’s hostname. > > There are always exceptions of course. There are cases where I want Puppet to distribute a file to the same path with different contents. What I usually do there is use the hostname in the filename on the Puppetmaster (which has no bearing on the client). For example: > > file { "replicationconf": > name => "/etc/openldap/replication.conf", > ensure => file, > owner => "root", > group => "ldap", > mode => "640", > source => "puppet://puppet/files/$environment/ldap/$hostname.replication", > notify => Service["ldap”], > } > > Although, now that I think about it, the per-host changes in that example are so minimal, I should probably look into using `puppetVar` and a template for this file. > >I apologize for not being clear. I''m not so much interested in files that get copied around in LDAP. I was trying to invent a non-trivial example of a define. It ended up coming out *very* contrived. I''m more interested in general techniques for instantiating defines in LDAP nodes. I have defines that do all sorts of things; to list all of them and ask for advice on each and every one would take more time than its worth. Do I need to create a "wrapper" class for the define instantiation like this: class def_inst { definetest::optfile { "file1": fname => "foo"; "file2": fname => "bar"; } } And then I can use puppetClass: def_inst in LDAP? Thanks. John Guthrie jguthrie@limewire.com -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Jul 23, 2010, at 3:37 PM, John T. Guthrie wrote:> Do I need to create a "wrapper" class for the define instantiation like this: > > class def_inst { > definetest::optfile { > "file1": > fname => "foo"; > "file2": > fname => "bar"; > } > } > > And then I can use puppetClass: def_inst in LDAP?Basically, yes. I’ve only used define once to manage entries in `sudoers`, so I’m no authority, but I just created the define outside of any class and then called that define as needed within classes. To put it another way, the defines should be called from inside classes along with file, package, server and other resources. Creating a class exclusively to call a single define seems off to me, but of course I don’t know the details of your situation. -- Rob McBroom <http://www.skurfer.com/> Don''t try to tell me something is important to you if the whole of your “support” entails getting Congress to force *others* to spend time and money on it. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.