diff options
author | Brenton Leanhardt <bleanhar@redhat.com> | 2008-03-28 09:14:24 -0400 |
---|---|---|
committer | Brenton Leanhardt <bleanhar@redhat.com> | 2008-04-03 09:55:30 -0400 |
commit | 0eb8b72d713b76908a7314d2afae26c51cf3b850 (patch) | |
tree | caefe0c36ed5fd366f0b573a61274732ace18837 /plugins/puppet/provider/mysql_schema/mysql.rb | |
parent | 657845ad0181c3da2505b3f7c2df3982bdf085ea (diff) | |
download | puppet-mysql-0eb8b72d713b76908a7314d2afae26c51cf3b850.tar.gz puppet-mysql-0eb8b72d713b76908a7314d2afae26c51cf3b850.tar.xz puppet-mysql-0eb8b72d713b76908a7314d2afae26c51cf3b850.zip |
Adding mysql_schema type
Added definition wrap the creation of the various mysql types
Diffstat (limited to 'plugins/puppet/provider/mysql_schema/mysql.rb')
-rw-r--r-- | plugins/puppet/provider/mysql_schema/mysql.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/puppet/provider/mysql_schema/mysql.rb b/plugins/puppet/provider/mysql_schema/mysql.rb new file mode 100644 index 0000000..2b582c1 --- /dev/null +++ b/plugins/puppet/provider/mysql_schema/mysql.rb @@ -0,0 +1,29 @@ +require 'puppet/provider/package' + +Puppet::Type.type(:mysql_schema).provide(:mysql) do + + desc "Create a Mysql schema." + commands :mysqladmin => '/usr/bin/mysqladmin' + commands :mysql => '/usr/bin/mysql' + + def create + # Pipe the ddl to mysql + open("| #{command(:mysql)} -u root -p#{@resource[:rootpw]} #{@resource[:db]}", "w") do |pipe| + pipe.puts(File.read(@resource[:name])) + end + end + + def destroy + #noop + end + + def exists? + if mysql("-u", "root", "-p", @resource[:rootpw], "-NBe", "show tables", @resource[:db]).empty? + false + else + true + end + end +end + + |