newguy
2011-Jul-15 00:32 UTC
[Puppet Users] Using puppet to import database on client side
Hi guys I have database dump available on pastebin/exzxzxz I want the puppet server to download the dump from pastebin and store it at a fixed location(suppose /home/dump) and then open mysql on the client side(mysql is installed on the client) and run the import command so that the downloaded dump is used to make a database on the client . Please help guys. Both client and server are Ubuntu 10.04. 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.
newguy
2011-Jul-15 04:10 UTC
[Puppet Users] Re: Using puppet to import database on client side
Guys somebody please help!!!! On Jul 14, 5:32 pm, newguy <aimanparv...@gmail.com> wrote:> Hi guys > I have database dump available on pastebin/exzxzxz > > I want the puppet server to download the dump from pastebin and store > it at a fixed location(suppose /home/dump) and then open mysql on the > client side(mysql is installed on the client) and run the import > command so that the downloaded dump is used to make a database on the > client . > > Please help guys. > > Both client and server are Ubuntu 10.04. > > 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.
Al @ Lab42
2011-Jul-15 06:31 UTC
[Puppet Users] Re: Using puppet to import database on client side
The quick way is to apply a pair of exec resources on the client machine: - One that downloads the sql file and the other one (that requires the first one) that applies it. Something like: exec { "Retrieve $url": cwd => "$work_dir", command => "wget $url", creates => "$work_dir/$sql_filename", timeout => 3600, } exec { "Extract $sql_filename": command => "mysql $mysql_options < $work_dir/$sql_filename", unless => "command that checks if the queryfile has been processed", require => Exec["Retrieve $url"], } An alternative approach would be to use puppi to "deploy" the sql file using this define: http://github.com/example42/puppi/blob/master/manifests/project/mysql.pp In order to do this you should: - Include puppi in your modules ( http://github.com/example42/puppi ) - Write a define like for your client node puppi::project::mysql { "mysite_sql": source => "http://url_to/mysite.sql", mysql_user => "$mysql_user", mysql_host => "$mysql_host", mysql_database => "$mysql_database", mysql_password => "$mysql_password", report_email => "my@mail", enable => "true", } - MANUALLY TYPE "puppi deploy mysite_sql" on the client node (or trigger it via Puppet with an exec resource like the ones at the beginning). Note that this Puppi approach might be a bit overkill for your needs: if you have to apply the sql file statements only once the first approach is quicker, if you plan to manage more or less continuous application deployments where developers leave on http://url_to/mysite.sql the changes on the database they require, the puppi approach saves time in the long term (and gives a lot of extra features). My2c Al -- 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/-/5rmN0_gmyQ4J. 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.
Marek Dohojda
2011-Jul-15 06:43 UTC
Re: [Puppet Users] Re: Using puppet to import database on client side
Personally I don''t think using puppet for this would not be the best solution. However here is what I would do. Write a shell script to do what you need, and than use puppet''s EXEC statement to launch this command as needed. You could also use custom Fact for this. For instance have you custom script do the export, while within puppet class you have an "if" that looks if a particular fact is true. if it is set to true than launch that exec command to do copy and import on your other host. Does that make sense? -----Original Message----- From: newguy Sent: Thursday, July 14, 2011 10:10 PM To: Puppet Users Subject: [Puppet Users] Re: Using puppet to import database on client side Guys somebody please help!!!! On Jul 14, 5:32 pm, newguy <aimanparv...@gmail.com> wrote:> Hi guys > I have database dump available on pastebin/exzxzxz > > I want the puppet server to download the dump from pastebin and store > it at a fixed location(suppose /home/dump) and then open mysql on the > client side(mysql is installed on the client) and run the import > command so that the downloaded dump is used to make a database on the > client . > > Please help guys. > > Both client and server are Ubuntu 10.04. > > 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. -- 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.
newguy
2011-Jul-15 17:03 UTC
[Puppet Users] Re: Using puppet to import database on client side
Yes Marek, it does make sense and thanks for this help, lemme try what Al @ Lab42 has suggested first as I have been told to do things by Puppet. In case I fail then I will look in to your suggestion. Thanks anyways On Jul 14, 11:43 pm, "Marek Dohojda" <chro...@gmail.com> wrote:> Personally I don''t think using puppet for this would not be the best > solution. However here is what I would do. Write a shell script to do what > you need, and than use puppet''s EXEC statement to launch this command as > needed. > > You could also use custom Fact for this. > > For instance have you custom script do the export, while within puppet class > you have an "if" that looks if a particular fact is true. if it is set to > true than launch that exec command to do copy and import on your other host. > > Does that make sense? > > > > > > > > -----Original Message----- > From:newguy > Sent: Thursday, July 14, 2011 10:10 PM > To: Puppet Users > Subject: [Puppet Users] Re: Using puppet to import database on client side > > Guys somebody please help!!!! > > On Jul 14, 5:32 pm,newguy<aimanparv...@gmail.com> wrote: > > Hi guys > > I have database dump available on pastebin/exzxzxz > > > I want the puppet server to download the dump from pastebin and store > > it at a fixed location(suppose /home/dump) and then open mysql on the > > client side(mysql is installed on the client) and run the import > > command so that the downloaded dump is used to make a database on the > > client . > > > Please help guys. > > > Both client and server are Ubuntu 10.04. > > > 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 athttp://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.
newguy
2011-Jul-15 17:37 UTC
[Puppet Users] Re: Using puppet to import database on client side
Hey Thanks for the help, I was able to download the dump file successfully but when I try to execute the mysql command I get the following error: Could not run Puppet configuration client: ''mysql -uroot -pring parasol < download.php?i=hV0wsTfa'' is both unqualifed and specified no search path at /etc/puppet/environments/abcd/modules/vim/manifests/ init.pp:25 here is my exec where am trying to run mysql command: exec {"Get db": command => "mysql -uroot -proot papa < dumpfile.sql", require => exec["Retrieve dump"], } Thanks for your efforts On Jul 15, 10:03 am, newguy <aimanparv...@gmail.com> wrote:> Yes Marek, it does make sense and thanks for this help, lemme try what > Al @ Lab42 has suggested first as I have been told to do things by > Puppet. In case I fail then I will look in to your suggestion. > > Thanks anyways > > On Jul 14, 11:43 pm, "Marek Dohojda" <chro...@gmail.com> wrote: > > > > > > > > > Personally I don''t think using puppet for this would not be the best > > solution. However here is what I would do. Write a shell script to do what > > you need, and than use puppet''s EXEC statement to launch this command as > > needed. > > > You could also use custom Fact for this. > > > For instance have you custom script do the export, while within puppet class > > you have an "if" that looks if a particular fact is true. if it is set to > > true than launch that exec command to do copy and import on your other host. > > > Does that make sense? > > > -----Original Message----- > > From:newguy > > Sent: Thursday, July 14, 2011 10:10 PM > > To: Puppet Users > > Subject: [Puppet Users] Re: Using puppet to import database on client side > > > Guys somebody please help!!!! > > > On Jul 14, 5:32 pm,newguy<aimanparv...@gmail.com> wrote: > > > Hi guys > > > I have database dump available on pastebin/exzxzxz > > > > I want the puppet server to download the dump from pastebin and store > > > it at a fixed location(suppose /home/dump) and then open mysql on the > > > client side(mysql is installed on the client) and run the import > > > command so that the downloaded dump is used to make a database on the > > > client . > > > > Please help guys. > > > > Both client and server are Ubuntu 10.04. > > > > 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 athttp://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.
Nan Liu
2011-Jul-15 17:41 UTC
Re: [Puppet Users] Re: Using puppet to import database on client side
On Fri, Jul 15, 2011 at 10:37 AM, newguy <aimanparvaiz@gmail.com> wrote:> Hey > Thanks for the help, I was able to download the dump file successfully > but when I try to execute the mysql command I get the following error: > > Could not run Puppet configuration client: ''mysql -uroot -pring > > parasol < download.php?i=hV0wsTfa'' is both unqualifed and specified no > > search path at /etc/puppet/environments/abcd/modules/vim/manifests/ > init.pp:25 > > > > here is my exec where am trying to run mysql command: > > exec {"Get db": > command => "mysql -uroot -proot papa < dumpfile.sql", > require => exec["Retrieve dump"], > }You need to provide the full path to mysql such as /usr/bin/mysql, or supply the path. 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.
newguy
2011-Jul-15 18:17 UTC
[Puppet Users] Re: Using puppet to import database on client side
Yes I did that and got the following error: change from notrun to 0 failed: /usr/bin/mysql -uroot -pring parasol < download.php?i=hV0wsTfa returned 1 instead of one of [0] at /etc/ puppet/environments/ss/modules/vim/manifests/init.pp:29 This is my exec: exec {"Get db": command => "/usr/bin/mysql -uroot -pring parasol < download.php? i=hV0wsTfa", require => exec["Retrieve dump"], } Please help On Jul 15, 10:41 am, Nan Liu <n...@puppetlabs.com> wrote:> On Fri, Jul 15, 2011 at 10:37 AM,newguy<aimanparv...@gmail.com> wrote: > > Hey > > Thanks for the help, I was able to download the dump file successfully > > but when I try to execute the mysql command I get the following error: > > > Could not run Puppet configuration client: ''mysql -uroot -pring > > > parasol < download.php?i=hV0wsTfa'' is both unqualifed and specified no > > > search path at /etc/puppet/environments/abcd/modules/vim/manifests/ > > init.pp:25 > > > here is my exec where am trying to run mysql command: > > > exec {"Get db": > > command => "mysql -uroot -proot papa < dumpfile.sql", > > require => exec["Retrieve dump"], > > } > > You need to provide the full path to mysql such as /usr/bin/mysql, or > supply the path. > > 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.
Stefan Schulte
2011-Jul-15 18:32 UTC
Re: [Puppet Users] Re: Using puppet to import database on client side
On Fri, Jul 15, 2011 at 11:17:40AM -0700, newguy wrote:> Yes I did that and got the following error: > change from notrun to 0 failed: /usr/bin/mysql -uroot -pring parasol < > download.php?i=hV0wsTfa returned 1 instead of one of [0] at /etc/ > puppet/environments/ss/modules/vim/manifests/init.pp:29 > > This is my exec: > > exec {"Get db": > command => "/usr/bin/mysql -uroot -pring parasol < download.php? > i=hV0wsTfa", > require => exec["Retrieve dump"], > } > > > Please helpWell it meanst that you command exited with an exit code of 1 instead of 0. So the easiest way to debug this is to run the command by hand in a shell # /usr/bin/mysql -uroot -pring parasol < download.php?i=hV0wsTf # echo $? Is download.php?i=hV0wsTf really the filename? I would also suggest to provide the full path to the inputfile because you never know where someone runs puppet (or provide the cwd parameter to switch to the desired directory first) -Stefan -- 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.
newguy
2011-Jul-15 18:36 UTC
[Puppet Users] Re: Using puppet to import database on client side
Yes I did that and got the following error: change from notrun to 0 failed: /usr/bin/mysql -uroot -pring parasol < download.php?i=hV0wsTfa returned 1 instead of one of [0] at /etc/ puppet/environments/ss/modules/vim/manifests/init.pp:29 This is my exec: exec {"Get db": command => "/usr/bin/mysql -uroot -pring parasol < download.php? i=hwwws22s", require => exec["Retrieve dump"], } Please help On Jul 15, 10:41 am, Nan Liu <n...@puppetlabs.com> wrote:> On Fri, Jul 15, 2011 at 10:37 AM, newguy <aimanparv...@gmail.com> wrote: > > Hey > > Thanks for the help, I was able to download the dump file successfully > > but when I try to execute the mysql command I get the following error: > > > Could not run Puppet configuration client: ''mysql -uroot -pring > > > parasol < download.php?i=hV0wsTfa'' is both unqualifed and specified no > > > search path at /etc/puppet/environments/abcd/modules/vim/manifests/ > > init.pp:25 > > > here is my exec where am trying to run mysql command: > > > exec {"Get db": > > command => "mysql -uroot -proot papa < dumpfile.sql", > > require => exec["Retrieve dump"], > > } > > You need to provide the full path to mysql such as /usr/bin/mysql, or > supply the path. > > 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.
newguy
2011-Jul-15 18:47 UTC
[Puppet Users] Re: Using puppet to import database on client side
I tried the path /usr/bin but it showed the following error: change from notrun to 0 failed: /usr/bin/mysql -uroot -proot papa < filedump.sql returned 1 instead of one of [0] at /etc/puppet/ping/ modules/vim/manifests/init.pp:29 exec {"Get db": command => "/usr/bin/mysql -uroot -proot papa < dumpfile.sql", require => exec["Retrieve dump"], } Thanks for your efforts On Jul 15, 10:41 am, Nan Liu <n...@puppetlabs.com> wrote:> On Fri, Jul 15, 2011 at 10:37 AM, newguy <aimanparv...@gmail.com> wrote: > > Hey > > Thanks for the help, I was able to download the dump file successfully > > but when I try to execute the mysql command I get the following error: > > > Could not run Puppet configuration client: ''mysql -uroot -pring > > > parasol < download.php?i=hV0wsTfa'' is both unqualifed and specified no > > > search path at /etc/puppet/environments/abcd/modules/vim/manifests/ > > init.pp:25 > > > here is my exec where am trying to run mysql command: > > > exec {"Get db": > > command => "mysql -uroot -proot papa < dumpfile.sql", > > require => exec["Retrieve dump"], > > } > > You need to provide the full path to mysql such as /usr/bin/mysql, or > supply the path. > > 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.
Al @ Lab42
2011-Jul-16 04:03 UTC
[Puppet Users] Re: Using puppet to import database on client side
Seems like the command /usr/bin/mysql -uroot -proot papa < filedump.sql returns an error when executed. Try to run it directly to understand why and note that you have to eecute it only once and not at every Puppet runs, that is achieved with refreshonly => true, or unless => "a command that checks if the exec has been done and returns true", Al -- 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/-/d3cUqUNnMVQJ. 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.
Gabriel Filion
2011-Jul-16 08:33 UTC
Re: [Puppet Users] Re: Using puppet to import database on client side
On 11-07-15 02:47 PM, newguy wrote:> exec {"Get db": > command => "/usr/bin/mysql -uroot -proot papa < > dumpfile.sql", > require => exec["Retrieve dump"], > }if your .sql file name is written in a similar fashion in your manifests it probably errors out because it doesn''t find it. try using an absolute path to your dump file. e.g.: exec {"Get db": command => "/usr/bin/mysql -uroot -proot papa < /var/backups/mysql/dumpfile.sql", require => exec["Retrieve dump"], } -- Gabriel Filion -- 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.
newguy
2011-Jul-16 15:20 UTC
[Puppet Users] Re: Using puppet to import database on client side
It worked thanks forth help guys. Problem was not of dump file its that on client machine password was misspelt. Thanks anyways. On Jul 16, 1:33 am, Gabriel Filion <lelu...@gmail.com> wrote:> On11-07-15 02:47 PM, newguy wrote: > > > exec {"Get db": > > command => "/usr/bin/mysql -uroot -proot papa < > > dumpfile.sql", > > require => exec["Retrieve dump"], > > } > > if your .sql file name is written in a similar fashion in your manifests > it probably errors out because it doesn''t find it. try using an absolute > path to your dump file. > > e.g.: > > exec {"Get db": > command => "/usr/bin/mysql -uroot -proot papa < > /var/backups/mysql/dumpfile.sql", > require => exec["Retrieve dump"], > } > > -- > Gabriel Filion-- 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.