[Puppet Users] Re: exported resources and templating
Nevermind, I found it: http://projects.puppetlabs.com/projects/puppet/wiki/Generating_a_config_file_from_fragments On Aug 23, 9:21 am, jcbollinger wrote: > On Aug 22, 8:11 am, puppetlurker wrote: > > > > > > > > > > > Greetings, > > > I'm having an issue with my implementation of exported resources. I > > have a memcache server pool, and want to update the /etc/php.d/ > > memcache.ini with the ips of all the servers. Previously, I hard coded > > the $memcacheservers array in the node manifest and the template > > collected and populated the template. > > > Now that I'm moving to exported resouces, how do I get it to set an > > array in a way I can access it from a different scope? I tried moving > > the file { "/etc/php.d/memcache.ini": content => template(memcache/ > > memcache.ini.erb) to the resource function (I understand exported > > resources shoulld not define other resources), but it only populates > > the first server collected, and complains about a duplicate resource > > if I have more than 1 exported server. > > > I've tried defining the resource without the content the first time, > > then override the define with the content, but that only picks up the > > 2nd server. I've tried accessing the variable that gets populated > > after the Memcache::Servers <<| |>> but it doesn't get populated in > > this scope. I've tried looking up the > > scope.lookupvar('memcached::servers::memcacheservers') but the > > exported resource is a define not a class and I couldn't get it to > > work. I've tried just using a script to populate the file with the > > proper contents, but there is no way to ensure it is filled with all > > the servers, for example the script is executed out of order, > > replaced 3 times if there are 3 servers, and may contain 1, 2, or 3 > > servers after a puppet run. > > > Any suggestions? > > The way to do this with exported resources is for each node to export > a resource containing its own information only. The trick is choosing > the resource to use for this. > > The simplest case would be if "/etc/php.d/memcache.ini" supports some > kind of 'include' directive, especially if it understands globs. Then > each server can export its own (distinctly-named) file intended for > inclusion, and the node(s) that collect them need only to put the > appropriate 'include' directive(s) into the main memcache.ini. > > Alternatively, there is a module available that provides for building > files from fragments. Your server could export fragment resources of > the type defined by that module, and the node(s) that collect them > would use them to build the memcache.ini file. > > Remember: an exported resource is one that you make available for > other nodes to include in their catalogs, as if they were declared in > those nodes' own manifests. All the normal rules apply in the context > where they are collected. In particular, name and title uniqueness is > still required, but for exported resources you may get lost resource > data instead of Puppet errors when there are name collisions. > > John -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
[Puppet Users] Re: exported resources and templating
On Aug 23, 9:21 am, jcbollinger wrote: > The way to do this with exported resources is for each node to export > a resource containing its own information only. The trick is choosing > the resource to use for this. > > The simplest case would be if "/etc/php.d/memcache.ini" supports some > kind of 'include' directive, especially if it understands globs. Then > each server can export its own (distinctly-named) file intended for > inclusion, and the node(s) that collect them need only to put the > appropriate 'include' directive(s) into the main memcache.ini. > Yes, but I don't think I can do that in all my cases. This one ini file is part of a collection of files that need to be updated and I think all I need to do is to get all the right servers in one array all the templates can use. > Alternatively, there is a module available that provides for building > files from fragments. Your server could export fragment resources of > the type defined by that module, and the node(s) that collect them > would use them to build the memcache.ini file. > Which module would this be? I would like to read up on it and check it out. > John Thanks, John. puppetlurker -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
[Puppet Users] Re: exported resources and templating
Hmmm. I upgraded, but when running a test I get: /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- puppet/rails/resources (MissingSourceFile) # puppet help hostname err: no such file to load -- puppet/rails/resources There are: /usr/lib/ruby/site_ruby/1.8/puppet/parser/resource /usr/lib/ruby/site_ruby/1.8/puppet/parser/resource.rb but no resources. I'm think I'm up to date with ruby: ruby -v ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux] Is there an updated puppet gem that I am missing? Thanks again. On Aug 22, 10:45 am, Nan Liu wrote: > On Mon, Aug 22, 2011 at 6:11 AM, puppetlurker > > > > > > > > > > wrote: > > Greetings, > > > I'm having an issue with my implementation of exported resources. I > > have a memcache server pool, and want to update the /etc/php.d/ > > memcache.ini with the ips of all the servers. Previously, I hard coded > > the $memcacheservers array in the node manifest and the template > > collected and populated the template. > > > Now that I'm moving to exported resouces, how do I get it to set an > > array in a way I can access it from a different scope? I tried moving > > the file { "/etc/php.d/memcache.ini": content => template(memcache/ > > memcache.ini.erb) to the resource function (I understand exported > > resources shoulld not define other resources), but it only populates > > the first server collected, and complains about a duplicate resource > > if I have more than 1 exported server. > > > I've tried defining the resource without the content the first time, > > then override the define with the content, but that only picks up the > > 2nd server. I've tried accessing the variable that gets populated > > after the Memcache::Servers <<| |>> but it doesn't get populated in > > this scope. I've tried looking up the > > scope.lookupvar('memcached::servers::memcacheservers') but the > > exported resource is a define not a class and I couldn't get it to > > work. I've tried just using a script to populate the file with the > > proper contents, but there is no way to ensure it is filled with all > > the servers, for example the script is executed out of order, > > replaced 3 times if there are 3 servers, and may contain 1, 2, or 3 > > servers after a puppet run. > > > Any suggestions? > > I was looking at a similar issue where I need to export data, not > resource, and be able to lookup the data. It just happens that Dan has > published a prototype along the line of what you are looking > for:https://github.com/puppetlabs/puppetlabs-nodesearch > > Thanks, > > Nan -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
[Puppet Users] Re: exported resources and templating
This looks promising! I should be able to create a fact on some servers, then collect those servers in a template. I'm going to upgrade to test this out. Thanks, puppetlurker On Aug 22, 10:45 am, Nan Liu wrote: > On Mon, Aug 22, 2011 at 6:11 AM, puppetlurker > > > > > > > > > > wrote: > > Greetings, > > > I'm having an issue with my implementation of exported resources. I > > have a memcache server pool, and want to update the /etc/php.d/ > > memcache.ini with the ips of all the servers. Previously, I hard coded > > the $memcacheservers array in the node manifest and the template > > collected and populated the template. > > > Now that I'm moving to exported resouces, how do I get it to set an > > array in a way I can access it from a different scope? I tried moving > > the file { "/etc/php.d/memcache.ini": content => template(memcache/ > > memcache.ini.erb) to the resource function (I understand exported > > resources shoulld not define other resources), but it only populates > > the first server collected, and complains about a duplicate resource > > if I have more than 1 exported server. > > > I've tried defining the resource without the content the first time, > > then override the define with the content, but that only picks up the > > 2nd server. I've tried accessing the variable that gets populated > > after the Memcache::Servers <<| |>> but it doesn't get populated in > > this scope. I've tried looking up the > > scope.lookupvar('memcached::servers::memcacheservers') but the > > exported resource is a define not a class and I couldn't get it to > > work. I've tried just using a script to populate the file with the > > proper contents, but there is no way to ensure it is filled with all > > the servers, for example the script is executed out of order, > > replaced 3 times if there are 3 servers, and may contain 1, 2, or 3 > > servers after a puppet run. > > > Any suggestions? > > I was looking at a similar issue where I need to export data, not > resource, and be able to lookup the data. It just happens that Dan has > published a prototype along the line of what you are looking > for:https://github.com/puppetlabs/puppetlabs-nodesearch > > Thanks, > > Nan -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
[Puppet Users] exported resources and templating
Greetings, I'm having an issue with my implementation of exported resources. I have a memcache server pool, and want to update the /etc/php.d/ memcache.ini with the ips of all the servers. Previously, I hard coded the $memcacheservers array in the node manifest and the template collected and populated the template. Now that I'm moving to exported resouces, how do I get it to set an array in a way I can access it from a different scope? I tried moving the file { "/etc/php.d/memcache.ini": content => template(memcache/ memcache.ini.erb) to the resource function (I understand exported resources shoulld not define other resources), but it only populates the first server collected, and complains about a duplicate resource if I have more than 1 exported server. I've tried defining the resource without the content the first time, then override the define with the content, but that only picks up the 2nd server. I've tried accessing the variable that gets populated after the Memcache::Servers <<| |>> but it doesn't get populated in this scope. I've tried looking up the scope.lookupvar('memcached::servers::memcacheservers') but the exported resource is a define not a class and I couldn't get it to work. I've tried just using a script to populate the file with the proper contents, but there is no way to ensure it is filled with all the servers, for example the script is executed out of order, replaced 3 times if there are 3 servers, and may contain 1, 2, or 3 servers after a puppet run. Any suggestions? Thanks! -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.