Gonçalo
2010-May-26 12:03 UTC
[Puppet Users] Build nginx conf dynamically (depending on the upstream machines)
Hi there, im trying to set up puppet to manage a nginx server with load balancing. To achieve this i need to add every machine ip to the "upstream" conf of nginx. Doing this manually is easy, and all works fine, the problem is that i would like to have every upstream machine to "warn" the nginx to add that machine ip to the conf. This way i would not need to change the conf manually everytime i add/remove a machine. To solve this problem i only found one solution (untested yet), that would be have every upstream machine use Exported Resources to create a file with its ip:port on a folder on the nginx server, and then have a batch program creating the nginx conf, based on those files... Is there any elegant way to do this? I already posted this question on server fault (http://serverfault.com/ questions/145244/load-balancing-with-puppet), and at that time i was thinking of just write an include directive inside the upstream on the conf, but that is not accepted by nginx, so i only have the option above left..and the one someone can possibly say here :-) 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.
David Schmitt
2010-May-26 12:34 UTC
Re: [Puppet Users] Build nginx conf dynamically (depending on the upstream machines)
On 5/26/2010 2:03 PM, Gonçalo wrote:> Hi there, im trying to set up puppet to manage a nginx server with > load balancing. To achieve this i need to add every machine ip to the > "upstream" conf of nginx. Doing this manually is easy, and all works > fine, the problem is that i would like to have every upstream machine > to "warn" the nginx to add that machine ip to the conf. This way i > would not need to change the conf manually everytime i add/remove a > machine. > To solve this problem i only found one solution (untested yet), that > would be have every upstream machine use Exported Resources to create > a file with its ip:port on a folder on the nginx server, and then have > a batch program creating the nginx conf, based on those files... > Is there any elegant way to do this? > I already posted this question on server fault (http://serverfault.com/ > questions/145244/load-balancing-with-puppet), and at that time i was > thinking of just write an include directive inside the upstream on the > conf, but that is not accepted by nginx, so i only have the option > above left..and the one someone can possibly say here :-) > ThanksHi, as I''ve answered on SF, I''d recommend [R.I.Pienaar''s concat][1] module. With this you can export/collect configuration file snippets and concatenate them on the target into a single file. Best Regards, David [1]: http://github.com/ripienaar/puppet-concat -- dasz.at OG Tel: +43 (0)664 2602670 Web: http://dasz.at Klosterneuburg UID: ATU64260999 FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg -- 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.
Gonçalo Queirós
2010-May-26 18:18 UTC
Re: [Puppet Users] Build nginx conf dynamically (depending on the upstream machines)
Thank you David. That module helped me implement one of the proposed solutions. I though there might be something "prettier" to handle this kind of situations, but seems not. Thanks for your module :-) On 05/26/2010 01:34 PM, David Schmitt wrote:> On 5/26/2010 2:03 PM, Gonçalo wrote: >> Hi there, im trying to set up puppet to manage a nginx server with >> load balancing. To achieve this i need to add every machine ip to the >> "upstream" conf of nginx. Doing this manually is easy, and all works >> fine, the problem is that i would like to have every upstream machine >> to "warn" the nginx to add that machine ip to the conf. This way i >> would not need to change the conf manually everytime i add/remove a >> machine. >> To solve this problem i only found one solution (untested yet), that >> would be have every upstream machine use Exported Resources to create >> a file with its ip:port on a folder on the nginx server, and then have >> a batch program creating the nginx conf, based on those files... >> Is there any elegant way to do this? >> I already posted this question on server fault (http://serverfault.com/ >> questions/145244/load-balancing-with-puppet), and at that time i was >> thinking of just write an include directive inside the upstream on the >> conf, but that is not accepted by nginx, so i only have the option >> above left..and the one someone can possibly say here :-) >> Thanks > > Hi, > > as I''ve answered on SF, I''d recommend [R.I.Pienaar''s concat][1] > module. With this you can export/collect configuration file snippets > and concatenate them on the target into a single file. > > Best Regards, David > > [1]: http://github.com/ripienaar/puppet-concat-- 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.
Daniel Pittman
2010-May-27 03:10 UTC
Re: [Puppet Users] Build nginx conf dynamically (depending on the upstream machines)
Gonçalo Queirós <goncaloqueiros@gmail.com> writes:> That module helped me implement one of the proposed solutions. I though > there might be something "prettier" to handle this kind of situations, > but seems not.Nope. That is the "best practice" mechanism for doing this. Sorry. Daniel -- ✣ Daniel Pittman ✉ daniel@rimspace.net ☎ +61 401 155 707 ♽ made with 100 percent post-consumer electrons -- 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.
David Schmitt
2010-May-28 16:25 UTC
Re: [Puppet Users] Build nginx conf dynamically (depending on the upstream machines)
On 27.05.2010 05:10, Daniel Pittman wrote:> Gonçalo Queirós<goncaloqueiros@gmail.com> writes: > >> That module helped me implement one of the proposed solutions. I though >> there might be something "prettier" to handle this kind of situations, >> but seems not. > > Nope. That is the "best practice" mechanism for doing this. Sorry.Not quite. Best practice would be to implement a native type which parses out the config file, but that involves ruby. Best Regards, David -- 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.
Nicolas Szalay
2010-Jun-01 13:20 UTC
Re: [Puppet Users] Build nginx conf dynamically (depending on the upstream machines)
Le mercredi 26 mai 2010 à 05:03 -0700, Gonçalo a écrit : Hello Gonçalo> Hi there, im trying to set up puppet to manage a nginx server with > load balancing. To achieve this i need to add every machine ip to the > "upstream" conf of nginx. Doing this manually is easy, and all works > fine, the problem is that i would like to have every upstream machine > to "warn" the nginx to add that machine ip to the conf. This way i > would not need to change the conf manually everytime i add/remove a > machine. > To solve this problem i only found one solution (untested yet), that > would be have every upstream machine use Exported Resources to create > a file with its ip:port on a folder on the nginx server, and then have > a batch program creating the nginx conf, based on those files... > Is there any elegant way to do this? > I already posted this question on server fault (http://serverfault.com/ > questions/145244/load-balancing-with-puppet), and at that time i was > thinking of just write an include directive inside the upstream on the > conf, but that is not accepted by nginx, so i only have the option > above left..and the one someone can possibly say here :-) > ThanksI do this with templates with embedded ruby. This is not the best practice, it''s pretty far away from it. Your solution with exported resources is almost the same, except the fact you''re using file (when I''m using a database) The only problem I see is when you have multiple upstream : how will you know in which upstream you want a server to be ? Regarding the concat module I don''t see how to use it for this because some "calculations" have to be made. To me the only "quick" solution is a template embedding ruby, and the only "clean" solution is a native type (longer to do/test/maintain) as David suggests. My 2c Nico.