From d33c7aa10e3a4bd9e97e947c471ee3ed36e9d1e2 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Oct 2007 17:23:20 +0200 Subject: mysql: implement native types and test them --- plugins/puppet/provider/mysql_user/mysql.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 plugins/puppet/provider/mysql_user/mysql.rb (limited to 'plugins/puppet/provider/mysql_user/mysql.rb') diff --git a/plugins/puppet/provider/mysql_user/mysql.rb b/plugins/puppet/provider/mysql_user/mysql.rb new file mode 100644 index 0000000..a1c2896 --- /dev/null +++ b/plugins/puppet/provider/mysql_user/mysql.rb @@ -0,0 +1,19 @@ +Puppet::Type.type(:mysql_user).provide(:mysql) do + desc "Use mysql as database." + commands :mysql => '/usr/bin/mysql' + + def create + mysql "mysql", "-e", "create user '%s@%s' identified by '%s'" % [ @resource[:name], @resource[:host], @resource[:password] ] + end + def destroy + mysql "mysql", "-e", "drop user '%s@%s'" % [ @resource[:name], @resource[:host] ] + end + def exists? + if /^#{@resource[:name]}@#{@resource[:host]}$/.match( mysql( "mysql", "-Be", 'SELECT CONCAT(user, "@", host) FROM user' ) ) + true + else + false + end + end +end + -- cgit