Doug Warner
2010-Mar-10 13:18 UTC
[Puppet Users] Using puppet to automate tasks (ex: mysql slave setup)
I''m not sure if puppet can be coerced to do something like this, but I wanted to throw it out there as it''s a process that seems fairly easy to automate. To create new mysql slaves my process goes something like this: 1) run innobackupex [1] on mysql master 2a) copy data from master to slave (takes a decent amount of time depending on wire speed and database size; usually on the order of 6-24 hrs) 2b) setup mysql slave w/ data from mysql master to start replicating binary log 3) import backup using innobackupex The problem here seems to be that I need to do things on two different hosts and only once certain things have happened. I figured I could easily specify the node that is the master and the slave in the manifests, but I''m not sure how far this gets me. I imagine through the creative use of exec''s and "onlyif"s this should be doable, but I wanted to get other people''s experiences with automating processes like this. -Doug [1] http://www.percona.com/docs/wiki/percona-xtrabackup:xtrabackup_manual#setting_up_a_new_slave_from_a_backup_in_replication
Tim Stoop
2010-Mar-10 13:39 UTC
[Puppet Users] Re: Using puppet to automate tasks (ex: mysql slave setup)
Hi Doug, On 10 mrt, 14:18, Doug Warner <d...@warner.fm> wrote:> I''m not sure if puppet can be coerced to do something like this, but I wanted > to throw it out there as it''s a process that seems fairly easy to automate. > > To create new mysql slaves my process goes something like this:<snip>> I figured I could easily specify the node that is the master and the slave in > the manifests, but I''m not sure how far this gets me. I imagine through the > creative use of exec''s and "onlyif"s this should be doable, but I wanted to > get other people''s experiences with automating processes like this.Although the idea is cool and I''d love to see the module once you have created it, I doubt this is something you really want to do with puppet. I see puppet more as a "this is what my machine should look like" kinda tool. Pushing data for several hours really shouldn''t be part of that, I think. I can imagine it triggering a script in the background that fetches like the daily backup from a server and builds the slave the next time puppet runs and it detects the download being completed, though. But that would still give you puppet errors for several hours (dependencies not being satisfied), which would indicate to me it''s not the right tool for the job. But maybe that''s just me. -- Kind regards, Tim -- 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.
Doug Warner
2010-Mar-10 15:10 UTC
Re: [Puppet Users] Re: Using puppet to automate tasks (ex: mysql slave setup)
On 03/10/2010 08:39 AM, Tim Stoop wrote:> Although the idea is cool and I''d love to see the module once you have > created it, I doubt this is something you really want to do with > puppet. I see puppet more as a "this is what my machine should look > like" kinda tool. Pushing data for several hours really shouldn''t be > part of that, I think. I can imagine it triggering a script in the > background that fetches like the daily backup from a server and builds > the slave the next time puppet runs and it detects the download being > completed, though. But that would still give you puppet errors for > several hours (dependencies not being satisfied), which would indicate > to me it''s not the right tool for the job. But maybe that''s just me.That''s kinda my impression as well. The manifests would have to be carefully crafted for "if this is here, do this now" which is going to be very trick across systems. I haven''t used Capistrano yet, but would a tool like that be better suited for this type of job? -Doug
Byron Pezan
2010-Mar-10 18:32 UTC
RE: [Puppet Users] Using puppet to automate tasks (ex: mysql slave setup)
In my environment I''d probably do something like this with Func (https://fedorahosted.org/func/). It''s primarily used with RedHat based systems. If that''s not a problem for you, then you can write scripts on your "overlord" that run commands on any systems running the func daemon and reporting to your "overlord". Your specific issue could be solved mostly with the "Command" and "CopyFile" module or, with a little Python experience, you could write your own module using the available api. It takes some work getting Func implemented but can be done quite easily with an existing puppet infrastructure or with something like Cobbler. byron -----Original Message----- From: puppet-users@googlegroups.com [mailto:puppet-users@googlegroups.com] On Behalf Of Doug Warner Sent: Wednesday, March 10, 2010 8:19 AM To: puppet-users@googlegroups.com Subject: [Puppet Users] Using puppet to automate tasks (ex: mysql slave setup) I''m not sure if puppet can be coerced to do something like this, but I wanted to throw it out there as it''s a process that seems fairly easy to automate. To create new mysql slaves my process goes something like this: 1) run innobackupex [1] on mysql master 2a) copy data from master to slave (takes a decent amount of time depending on wire speed and database size; usually on the order of 6-24 hrs) 2b) setup mysql slave w/ data from mysql master to start replicating binary log 3) import backup using innobackupex The problem here seems to be that I need to do things on two different hosts and only once certain things have happened. I figured I could easily specify the node that is the master and the slave in the manifests, but I''m not sure how far this gets me. I imagine through the creative use of exec''s and "onlyif"s this should be doable, but I wanted to get other people''s experiences with automating processes like this. -Doug [1] http://www.percona.com/docs/wiki/percona-xtrabackup:xtrabackup_manual#setting_up_a_new_slave_from_a_backup_in_replication -- 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.
Luke Kanies
2010-Mar-12 01:24 UTC
Re: [Puppet Users] Using puppet to automate tasks (ex: mysql slave setup)
On Mar 10, 2010, at 5:18 AM, Doug Warner wrote:> I''m not sure if puppet can be coerced to do something like this, but > I wanted > to throw it out there as it''s a process that seems fairly easy to > automate. > > To create new mysql slaves my process goes something like this: > > 1) run innobackupex [1] on mysql master > 2a) copy data from master to slave (takes a decent amount of time > depending on > wire speed and database size; usually on the order of 6-24 hrs) > 2b) setup mysql slave w/ data from mysql master to start replicating > binary log > 3) import backup using innobackupex > > The problem here seems to be that I need to do things on two > different hosts > and only once certain things have happened. > > I figured I could easily specify the node that is the master and the > slave in > the manifests, but I''m not sure how far this gets me. I imagine > through the > creative use of exec''s and "onlyif"s this should be doable, but I > wanted to > get other people''s experiences with automating processes like this.Hi Doug, I, um, don''t know if this is a good idea, but this might work for you: http://github.com/reductivelabs/puppet-external-resource Basically, I''ve created a simple resource that functions as a kind of gate for exactly that situation. I''ve tested it in very simplistic situations, but you should consider this to be experimental code and by no means a complete solution. I just made this repo public five minutes ago and wrote it for a customer last week. For long delays -- 12 hours -- this will likely be pretty spammy, because you''ll get a lot of ''skipped because of failed dependencies'' reports, and you''ll likely want to run it with a timeout of 0 and verify that it works correctly in that case. With this, your slave would have something like: class dbslave { external_resource { db-backup: check => "..script to verify backup is complete..." } db::import { mydb: ...., require => External_resource[db-backup] } } By default, it''ll run the external resource check every 10 seconds, and if it doesn''t complete within five minutes then it fails, causing all dependent resources (in this case, your import) to be skipped. You can tune both the frequency and timeout, but I haven''t tested it with a timeout of 0; it might just sleep infinitely in that case. -- There is only one success - to be able to spend your life in your own way. -- Christopher Morley --------------------------------------------------------------------- Luke Kanies -|- http://reductivelabs.com -|- +1(615)594-8199 -- 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.