I am looking to extend one of the puppet modules -"mysql". I found that they are extending Puppet with types and providers. First off I am having a difficult time find any documentationo on this and I do not know Ruby that well. The problem that I am having is this, I have the following code: Puppet::Type.type(:database).provide(:mysql) do desc "Manages MySQL database." defaultfor :kernel => ''Linux'' optional_commands :mysql => ''mysql'' def create def create mysql("-u #{resource[:rootuser]} -p\''#{resource[:rootpassword]}\'' -h #{resource[:host]} -NBev", "create database #{@resource[:name]} character set #{resource[:charset]}") end It fails with the following error, if I run the command on the command line it runs successfully but in Puppet it fails. Can someone help me understand how the mysql is being executed with mysql? debug: Puppet::Type::Database::ProviderMysql: Executing ''/usr/bin/mysql -u admin -p''password'' -h vm-minux.comm.com -NBev create database mydb character set utf8'' err: /Stage[main]//Node[ssat-puppetagent-1.qcomm.com]/Test_mod::Db[mydb]/Database[mydb]/ensure: change from absent to present failed: Execution of ''/usr/bin/mysql -u admin -p''password'' -h vm-mlinux.qcomm.com -NBev create database mydb character set utf8'' returned 1: ERROR 1044 (42000): Access denied for user ''''@''localhost'' to database ''create database mydb character set utf8'' PE 2.5.1 -- 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/-/gPqNsft3rAYJ. 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.
On Fri, Aug 10, 2012 at 08:51:33PM -0700, Mike Carr wrote:> I am looking to extend one of the puppet modules -"mysql". I found that they are extending Puppet with types and providers. First off I am having a difficult time find any documentationo on this and I do not know Ruby that well. The problem that I am having is this, I have the following code: > > Puppet::Type.type(:database).provide(:mysql) do > desc "Manages MySQL database." > > defaultfor :kernel => ''Linux'' > > optional_commands :mysql => ''mysql''This will automatically define a method called mysql you can use later.> > def create > def create > mysql("-u #{resource[:rootuser]} -p\''#{resource[:rootpassword]}\'' -h #{resource[:host]} -NBev", "create database #{@resource[:name]} character set #{resource[:charset]}") > end >The mysql method does not use a shell to execute your command, instead every argument you pass to the mysql method is passed as an argument to the mysql executable. So in your case mysql is only executed with one huge argument. What you want is: mysql( ''-u'', resource[:rootuser], ''-p'', resource[:rootpassword], ''-h'', resource[:host], ''-NBev'', "create database #{resource[:name]} character set #{resource[:charset]}" ) -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.
Awesome, thanks! Is this a feature of Ruby or Puppet? -- 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/-/H5Mk5syctXEJ. 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.