Stefan Schulte
unread,Aug 11, 2012, 8:33:03 AM8/11/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
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