Luca Lesinigo
2012-Nov-27 17:03 UTC
[Puppet Users] How to populate files on nodes with data from a MySQL table, via Puppet
[originally asked on ServerFault <http://serverfault.com/q/452522/35909>, but doesn''t seem to get much traction there] I have some data (hundreds of rows, should grow to some thousands in a worst case scenario), managed from external sources, whose authoritative source of truth consists of MySQL tables: I want to populate some files on some nodes with that data, the nodes cannot talk directly to MySQL, I can already do that with some scriptery and rsync or something, but I''d like to use Puppet-3 to do that. Possible usage scenarios are things like Postfix transport maps, Spamassassin rules / custom settings per recipient, DJBDNS data files, Apache/nginx virtual hosts, and so on. Please do note this kind of data is managed by external sources outside of Puppet''s control. What is the recommended approach to manage them through Puppet? I can imagine dumping data from MySQL to YAML files on the master and try something with Hiera, I can also export data from MySQL to pre-formatted text files in the filebucket and distribute them. But I also think / hope there is a better way for this use case. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Q40qNWqUtWgJ. 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.
jcbollinger
2012-Nov-27 20:52 UTC
[Puppet Users] Re: How to populate files on nodes with data from a MySQL table, via Puppet
On Tuesday, November 27, 2012 11:03:25 AM UTC-6, Luca Lesinigo wrote:> > [originally asked on ServerFault <http://serverfault.com/q/452522/35909>, > but doesn''t seem to get much traction there] > > I have some data (hundreds of rows, should grow to some thousands in a > worst case scenario), managed from external sources, whose authoritative > source of truth consists of MySQL tables: I want to populate some files on > some nodes with that data, the nodes cannot talk directly to MySQL, I can > already do that with some scriptery and rsync or something, but I''d like to > use Puppet-3 to do that. > > Possible usage scenarios are things like Postfix transport maps, > Spamassassin rules / custom settings per recipient, DJBDNS data files, > Apache/nginx virtual hosts, and so on. Please do note this kind of data is > managed by external sources outside of Puppet''s control. > > What is the recommended approach to manage them through Puppet? I can > imagine dumping data from MySQL to YAML files on the master and try > something with Hiera, I can also export data from MySQL to pre-formatted > text files in the filebucket and distribute them. > But I also think / hope there is a better way for this use case. >Hiera supports pluggable back ends. I would consider writing a back-end that loads the requested data directly from your database. Your manifests don''t need to know which data come from the DB and which from elsewhere. If that doesn''t seem suitable, then you can write one or more custom functions that query the needed data from your database. I would avoid dumping the data to a secondary store, as that presents a freshness problem. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/yUKq9dyKLeEJ. 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.