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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Mon, Aug 22, 2011 at 6:11 AM, puppetlurker <under.my.control@gmail.com> 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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 <n...@puppetlabs.com> wrote:> On Mon, Aug 22, 2011 at 6:11 AM, puppetlurker > > > > > > > > > > <under.my.cont...@gmail.com> 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Aug 22, 8:11 am, puppetlurker <under.my.cont...@gmail.com> 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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 <n...@puppetlabs.com> wrote:> On Mon, Aug 22, 2011 at 6:11 AM, puppetlurker > > > > > > > > > > <under.my.cont...@gmail.com> 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Aug 23, 9:21 am, jcbollinger <John.Bollin...@stJude.org> 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.> JohnThanks, 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nevermind, I found it: http://projects.puppetlabs.com/projects/puppet/wiki/Generating_a_config_file_from_fragments On Aug 23, 9:21 am, jcbollinger <John.Bollin...@stJude.org> wrote:> On Aug 22, 8:11 am, puppetlurker <under.my.cont...@gmail.com> 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Tue, Aug 23, 2011 at 3:09 AM, puppetlurker <under.my.control@gmail.com>wrote:> 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. > >Another option, just in case you dont want to upgrade your puppet installation / use storconfigs and you want to get results based on the state of your nodes (e.g. no stale nodes, nodes with errors etc) is to query foreman [1], a simple example of a puppet function can be found here [2] Ohad [1] - http://theforeman.org [2] - https://github.com/ohadlevy/puppet-foreman/blob/master/foreman/lib/puppet/parser/functions/foreman.rb Thanks,> > puppetlurker > > On Aug 22, 10:45 am, Nan Liu <n...@puppetlabs.com> wrote: > > On Mon, Aug 22, 2011 at 6:11 AM, puppetlurker > > > > > > > > > > > > > > > > > > > > <under.my.cont...@gmail.com> 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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.
Robin Lee Powell
2011-Sep-22 00:35 UTC
Re: [Puppet Users] Re: exported resources and templating
On Tue, Aug 23, 2011 at 06:21:48AM -0700, jcbollinger wrote:> > > On Aug 22, 8:11 am, puppetlurker <under.my.cont...@gmail.com> 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.So you can''t do this with your own defines as the resource? I have various define calls like this: users::normal { bob: id => 107, email => ''bob@bob.com'' } What I''m looking to do is collect all the emails into an array or something so I can use them in a template. I thought maybe I could make a define that does an array append or something? It sounds from what people are saying like there really isn''t a reasonable way to do this yet? -Robin -- http://singinst.org/ : Our last, best hope for a fantastic future. Lojban (http://www.lojban.org/): The language in which "this parrot is dead" is "ti poi spitaki cu morsi", but "this sentence is false" is "na nei". My personal page: http://www.digitalkingdom.org/rlp/ -- 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 Sep 21, 7:35 pm, Robin Lee Powell <rlpow...@digitalkingdom.org> wrote:> On Tue, Aug 23, 2011 at 06:21:48AM -0700, jcbollinger wrote: > > > On Aug 22, 8:11 am, puppetlurker <under.my.cont...@gmail.com> 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. > > So you can''t do this with your own defines as the resource?It depends what "this" is. You certainly can export and collect instances of a defined type.> I have various define calls like this: > > users::normal { bob: id => 107, email => ''...@bob.com'' } > > What I''m looking to do is collect all the emails into an array or > something so I can use them in a template.It sounds like your problem is that you don''t in fact want to collect *resources* at all -- rather, you want to collect *data*. That is not what exported resources are for.> I thought maybe I could make a define that does an array append or > something?Do not confuse a Puppet defined type with a CPP "#define" macro. They are not analogous. Strictly speaking, an instance of a Puppet defined type doesn''t *do* anything; it rather declares a logical resource for Puppet to manage on the node in question. Exported resources are resources intended to be managed on nodes other than (or in addition to) the one declaring them. There is necessarily an aspect of data sharing to that, but they should not be viewed as a vehicle for data sharing.> It sounds from what people are saying like there really isn''t a > reasonable way to do this yet?Again, it depends on what "this" is, but I think you are approaching the problem backwards. If you need centralized data then you should create a data source and use it to drive your resource declarations wherever appropriate. Details depend a lot on your general approach and the complexity of the data, but if you want to access your shared data store from within Puppet itself then I''d recommend looking into hiera. More generally, there is no good way for manifests to extract data from declared (or collected) resources, and I am unaware of any plans to change that. I do not personally think it a problem that should be solved. 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Robin Lee Powell
2011-Sep-22 17:39 UTC
Re: [Puppet Users] Re: exported resources and templating
Thanks for the detailed reply! On Thu, Sep 22, 2011 at 07:18:13AM -0700, jcbollinger wrote:> > It sounds like your problem is that you don''t in fact want to > collect *resources* at all -- rather, you want to collect *data*. > That is not what exported resources are for.That''s entirely correct. I knew I was hacking around a "not really designed to do this", I just thought it might be possible anyway.> Exported resources are resources intended to be managed on nodes > other than (or in addition to) the one declaring them. There is > necessarily an aspect of data sharing to that, but they should not > be viewed as a vehicle for data sharing.OK.> > It sounds from what people are saying like there really isn''t a > > reasonable way to do this yet? > > Again, it depends on what "this" is, but I think you are > approaching the problem backwards. If you need centralized data > then you should create a data source and use it to drive your > resource declarations wherever appropriate. Details depend a lot > on your general approach and the complexity of the data, but if > you want to access your shared data store from within Puppet > itself then I''d recommend looking into hiera.The data right now is *incredibly* simple; just a list of email addresses (one for each user defined on each host everywhere). Adding a whole data source system just for that seems like significant overkill. Using the @@file trick, while cheating as you say, seems a lot less effort until/unless Puppet integrates some method of data sharing. Note that by "integrates" there I don''t mean "comes with" or anything, more like "I can run a couple of yum installs and tweak a couple of config variables and it works", which I''m pretty sure isn''t the case now for any such shared data stores. To be more specific, I have user definitions in my site.pp for various users that have accounts on various hosts. The user defines currently look like this: users::normal { bob: id => 111, email => ''bob@bob.com'' } and that is used to set up various things about that user on the host that it''s defined on (i.e. the actual account). I would, in addition, like to collect all the email addresses in one place on a particular host. I''m actually not sure that Hiera would solve the problem anyway; if I have a list of user information stored in a Hiera .yaml file, it''s not at all obvious to me how to access the email addresses in such away as to make them available all at once in a template somewhere. I suppose if I could walk the Hiera tree in a template that would work; is that possible? -Robin -- http://singinst.org/ : Our last, best hope for a fantastic future. Lojban (http://www.lojban.org/): The language in which "this parrot is dead" is "ti poi spitaki cu morsi", but "this sentence is false" is "na nei". My personal page: http://www.digitalkingdom.org/rlp/ -- 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 Sep 22, 12:39 pm, Robin Lee Powell <rlpow...@digitalkingdom.org> wrote:> Thanks for the detailed reply! > > On Thu, Sep 22, 2011 at 07:18:13AM -0700, jcbollinger wrote: > > > It sounds like your problem is that you don''t in fact want to > > collect *resources* at all -- rather, you want to collect *data*. > > That is not what exported resources are for. > > That''s entirely correct. I knew I was hacking around a "not really > designed to do this", I just thought it might be possible anyway. > > > Exported resources are resources intended to be managed on nodes > > other than (or in addition to) the one declaring them. There is > > necessarily an aspect of data sharing to that, but they should not > > be viewed as a vehicle for data sharing. > > OK. > > > > It sounds from what people are saying like there really isn''t a > > > reasonable way to do this yet? > > > Again, it depends on what "this" is, but I think you are > > approaching the problem backwards. If you need centralized data > > then you should create a data source and use it to drive your > > resource declarations wherever appropriate. Details depend a lot > > on your general approach and the complexity of the data, but if > > you want to access your shared data store from within Puppet > > itself then I''d recommend looking into hiera. > > The data right now is *incredibly* simple; just a list of email > addresses (one for each user defined on each host everywhere). > Adding a whole data source system just for that seems like > significant overkill. > > Using the @@file trick, while cheating as you say, seems a lot less > effort until/unless Puppet integrates some method of data sharing. > Note that by "integrates" there I don''t mean "comes with" or > anything, more like "I can run a couple of yum installs and tweak a > couple of config variables and it works", which I''m pretty sure > isn''t the case now for any such shared data stores.You are missing the obvious: anything in your manifests themselves is at least potentially available to all nodes. Taking your e-mail address example, you can do this: class email { $addresses = { ''alice'' => ''...@alice.com'', ''bob'' => ''...@bob.com'', ... ''zoe'' => ''...@foo.net'' } } There''s your data store. You can then remove the ''email'' parameter from users::normal, and instead have it look up the e-mail address: define users::normal ($id) { $email = $email::addresses[$name] ... } And the whole of $email::addresses is sitting there for any node that wants it. That approach works best for fairly simple data, but there''s no inherent barrier to making the data as complex as you like. As a practical matter, however, you might want to externalize the data so that you don''t have to modify your manifests to update it. That''s part of what a tool such as hiera could do for you: it might, for example, load the data from a file and present the hash value to you. Moreover, it abstracts the actual data source so that at the point of use, your manifests don''t need to know whether the data is coming from DSL variables, a flat file, a database, etc. Why then, you may ask, are exported resources useful? Why not take a fully data-driven approach along the lines above? I''m glad you asked. Exported resources can do something that the above approach cannot: their properties and even their very existence can depend on the facts pertinent to the nodes exporting them. If you are considering a use of exported resources that doesn''t somehow leverage that characteristic, then you are looking at the wrong tool. John 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Robin Lee Powell
2011-Sep-23 03:25 UTC
Re: [Puppet Users] Re: exported resources and templating
On Thu, Sep 22, 2011 at 02:24:45PM -0700, jcbollinger wrote:> > You are missing the obvious:I had a feeling I might be.> anything in your manifests themselves is at least potentially > available to all nodes. Taking your e-mail address example, you > can do this: > > class email { > $addresses = { > ''alice'' => ''...@alice.com'', > ''bob'' => ''...@bob.com'', > ... > ''zoe'' => ''...@foo.net'' > } > } > > There''s your data store. You can then remove the ''email'' > parameter from users::normal, and instead have it look up the > e-mail address: > > define users::normal ($id) { > $email = $email::addresses[$name] > ... > } > > And the whole of $email::addresses is sitting there for any node > that wants it.That''s pretty excellent. Thank you.> Why then, you may ask, are exported resources useful? Why not > take a fully data-driven approach along the lines above? I''m glad > you asked. Exported resources can do something that the above > approach cannot: their properties and even their very existence > can depend on the facts pertinent to the nodes exporting them. If > you are considering a use of exported resources that doesn''t > somehow leverage that characteristic, then you are looking at the > wrong tool.Where I''ve found them useful, fwiw, is for /etc/hosts and ssh_known_hosts. Although even that could probably be put into a data-driven external something or other. -Robin -- http://singinst.org/ : Our last, best hope for a fantastic future. Lojban (http://www.lojban.org/): The language in which "this parrot is dead" is "ti poi spitaki cu morsi", but "this sentence is false" is "na nei". My personal page: http://www.digitalkingdom.org/rlp/ -- 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.