Hello, I am hoping that someone might be able to shed some light on the best way to solve an issue. https://github.com/puppetlabs/puppetlabs-apache/commit/c2c75a62b7dafced8a6120a14bacfc8be7539282<https://github.com/puppetlabs/puppetlabs-apache/commit/c2c75a62b7dafced8a6120a14bacfc8be7539282#commitcomment-1654941> This commit introduced functionality into the vhost type to ensure that the $docroot and $logroot exist. This is smart as Apache will throw a warning if $docroot does not exist and error out if $logroot does not exist. I believe the original intention of the author was to make the names of these resources unique so that multiple vhosts can share the same docroot and logroot (line 71-80). However, the path of the resources is not unique across vhosts that use the same $docroot and $logroot and therefore puppet will error out. The first thing that came to my mind was to make the resources virtual and then just realize a single directory. Unless something special needs done, marking the two file resources as virtual (@file) still does not work. The other option that has been discussed is to use a conditional if block: https://github.com/puppetlabs/puppetlabs-apache/pull/37/files Here, on all but one of the vhost entries, you mark ensure_dirs as false and Puppet will not enforce the existence of the two directories. This works, but it comes off as a workaround more than a proper solution. Any ideas? Thanks, Joe -- Joe Topjian Systems Administrator Cybera Inc. www.cybera.ca Cybera is a not-for-profit organization that works to spur and support innovation, for the economic benefit of Alberta, through the use of cyberinfrastructure. -- 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.
Dan Bode
2012-Aug-02 02:13 UTC
Re: [Puppet Users] duplicate resources across defined types
Hi Joe, On Tue, Jul 31, 2012 at 6:41 PM, Joe Topjian <joe.topjian@cybera.ca> wrote:> Hello, > > I am hoping that someone might be able to shed some light on the best way > to solve an issue. > > > https://github.com/puppetlabs/puppetlabs-apache/commit/c2c75a62b7dafced8a6120a14bacfc8be7539282<https://github.com/puppetlabs/puppetlabs-apache/commit/c2c75a62b7dafced8a6120a14bacfc8be7539282#commitcomment-1654941> >This is actually a pretty common modeling problem in Puppet. I just wrote a function called ensure_resource that is intended to solve this problem. https://github.com/bodepd/puppet-ensure_resource The function allows you to ensure that a resource should exist in the catalog. If the exact resource already exists in the catalog (meaning that it has the exact type, title, and specified parameters), it will not create the resource. Otherwise it will create the resource which could result in a duplicate resource definition if the resource already existed but had non-matching parameters. I would really like to see this incorporated into the apache module. thoughts? - Dan> This commit introduced functionality into the vhost type to ensure that > the $docroot and $logroot exist. This is smart as Apache will throw a > warning if $docroot does not exist and error out if $logroot does not exist. > > I believe the original intention of the author was to make the names of > these resources unique so that multiple vhosts can share the same docroot > and logroot (line 71-80). However, the path of the resources is not unique > across vhosts that use the same $docroot and $logroot and therefore puppet > will error out. > > The first thing that came to my mind was to make the resources virtual and > then just realize a single directory. Unless something special needs done, > marking the two file resources as virtual (@file) still does not work. > > The other option that has been discussed is to use a conditional if block: > > https://github.com/puppetlabs/puppetlabs-apache/pull/37/files > > Here, on all but one of the vhost entries, you mark ensure_dirs as false > and Puppet will not enforce the existence of the two directories. This > works, but it comes off as a workaround more than a proper solution. > > Any ideas? > > Thanks, > Joe > > > > -- > Joe Topjian > Systems Administrator > Cybera Inc. > > www.cybera.ca > > Cybera is a not-for-profit organization that works to spur and support > innovation, for the economic benefit of Alberta, through the use > of cyberinfrastructure. > > -- > 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.
Joe Topjian
2012-Aug-02 02:37 UTC
Re: [Puppet Users] duplicate resources across defined types
Hi Dan, This is actually a pretty common modeling problem in Puppet.>I figured it had to be common as this type of configuration can exist in a lot of other system administration areas.> I just wrote a function called ensure_resource that is intended to solve > this problem. > > https://github.com/bodepd/puppet-ensure_resource > > The function allows you to ensure that a resource should exist in the > catalog. > > If the exact resource already exists in the catalog (meaning that it has > the exact type, title, and specified parameters), it will not create the > resource. Otherwise it will create the resource which could result in a > duplicate resource definition if the resource already existed but had > non-matching parameters. > > I would really like to see this incorporated into the apache module. >I agree.> thoughts? >The only thing I am curious about now is the difference between this and a virtual resource? Maybe I was under the wrong impression about virtual resources... I thought that they did this same thing. Thank you for your help and work with this! Joe -- Joe Topjian Systems Administrator Cybera Inc. www.cybera.ca Cybera is a not-for-profit organization that works to spur and support innovation, for the economic benefit of Alberta, through the use of cyberinfrastructure. -- 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.
Dan Bode
2012-Aug-02 03:27 UTC
Re: [Puppet Users] duplicate resources across defined types
On Wed, Aug 1, 2012 at 7:37 PM, Joe Topjian <joe.topjian@cybera.ca> wrote:> Hi Dan, > > This is actually a pretty common modeling problem in Puppet. >> > > I figured it had to be common as this type of configuration can exist in a > lot of other system administration areas. > > >> I just wrote a function called ensure_resource that is intended to solve >> this problem. >> >> https://github.com/bodepd/puppet-ensure_resource >> >> The function allows you to ensure that a resource should exist in the >> catalog. >> >> If the exact resource already exists in the catalog (meaning that it has >> the exact type, title, and specified parameters), it will not create the >> resource. Otherwise it will create the resource which could result in a >> duplicate resource definition if the resource already existed but had >> non-matching parameters. >> >> I would really like to see this incorporated into the apache module. >> > > I agree. > > >> thoughts? >> > > The only thing I am curious about now is the difference between this and a > virtual resource? Maybe I was under the wrong impression about virtual > resources... I thought that they did this same thing. >virtual resources are definitely intended to solve the same problem, but they would not work for this use case b/c multiple declarations of the same virtual resource still result in the duplicate definition failures. virtual resources can also be problematic b/c collecting resources also realizes them as a side effect.> > > Thank you for your help and work with this! > Joe > > > -- > Joe Topjian > Systems Administrator > Cybera Inc. > > www.cybera.ca > > Cybera is a not-for-profit organization that works to spur and support > innovation, for the economic benefit of Alberta, through the use > of cyberinfrastructure. > > -- > 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.
Joe Topjian
2012-Aug-02 14:09 UTC
Re: [Puppet Users] duplicate resources across defined types
Hi Dan,> virtual resources are definitely intended to solve the same problem, but > they would not work for this use case b/c multiple declarations of the same > virtual resource still result in the duplicate definition failures. > > virtual resources can also be problematic b/c collecting resources also > realizes them as a side effect. >I see. Thank you. I incorporated the ensure_resource function into the vhost type: https://github.com/jtopjian/puppetlabs-apache/tree/jtopjian-ensure_resource It seems to pass the test manifest that I threw at it, but it is giving these warnings: /usr/lib/ruby/1.8/puppet/parser/functions/create_resources.rb:1: warning: multiple values for a block parameter (2 for 1) from /usr/lib/ruby/1.8/puppet/parser/scope.rb:464 /usr/lib/ruby/1.8/puppet/parser/functions/create_resources.rb:1: warning: multiple values for a block parameter (2 for 1) from /etc/puppet/modules/ensure_resource/lib/puppet/parser/functions/ensure_resource.rb:24 /usr/lib/ruby/1.8/puppet/parser/functions/create_resources.rb:1: warning: multiple values for a block parameter (2 for 1) from /etc/puppet/modules/ensure_resource/lib/puppet/parser/functions/ensure_resource.rb:24 Thanks, Joe -- Joe Topjian Systems Administrator Cybera Inc. www.cybera.ca Cybera is a not-for-profit organization that works to spur and support innovation, for the economic benefit of Alberta, through the use of cyberinfrastructure. -- 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.
Dan Bode
2012-Aug-02 16:00 UTC
Re: [Puppet Users] duplicate resources across defined types
On Thu, Aug 2, 2012 at 7:09 AM, Joe Topjian <joe.topjian@cybera.ca> wrote:> Hi Dan, > > >> virtual resources are definitely intended to solve the same problem, but >> they would not work for this use case b/c multiple declarations of the same >> virtual resource still result in the duplicate definition failures. >> >> virtual resources can also be problematic b/c collecting resources also >> realizes them as a side effect. >> > > I see. Thank you. > > I incorporated the ensure_resource function into the vhost type: > > https://github.com/jtopjian/puppetlabs-apache/tree/jtopjian-ensure_resource >I made a few inline comments> It seems to pass the test manifest that I threw at it, but it is giving > these warnings: > > /usr/lib/ruby/1.8/puppet/parser/functions/create_resources.rb:1: warning: > multiple values for a block parameter (2 for 1) > from /usr/lib/ruby/1.8/puppet/parser/scope.rb:464 > /usr/lib/ruby/1.8/puppet/parser/functions/create_resources.rb:1: warning: > multiple values for a block parameter (2 for 1) > from > /etc/puppet/modules/ensure_resource/lib/puppet/parser/functions/ensure_resource.rb:24 > /usr/lib/ruby/1.8/puppet/parser/functions/create_resources.rb:1: warning: > multiple values for a block parameter (2 for 1) > from > /etc/puppet/modules/ensure_resource/lib/puppet/parser/functions/ensure_resource.rb:24 >should be fixed in master.> > Thanks, > Joe > > > -- > Joe Topjian > Systems Administrator > Cybera Inc. > > www.cybera.ca > > Cybera is a not-for-profit organization that works to spur and support > innovation, for the economic benefit of Alberta, through the use > of cyberinfrastructure. > > -- > 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.
Joe Topjian
2012-Aug-02 16:10 UTC
Re: [Puppet Users] duplicate resources across defined types
> > I made a few inline comments >Thank you.> should be fixed in master. >Yup, looks good. I will open a pull request for this. -- Joe Topjian Systems Administrator Cybera Inc. www.cybera.ca Cybera is a not-for-profit organization that works to spur and support innovation, for the economic benefit of Alberta, through the use of cyberinfrastructure. -- 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.