From ce9a3a152fc180e2de297367ea1a87477eae9338 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 26 Jan 2013 13:04:42 -0200 Subject: More lib updates --- lib/facter/mysql.rb | 8 -------- lib/facter/mysql_exists.rb | 5 +++++ lib/facter/mysql_version.rb | 6 ++++++ lib/puppet/provider/mysql_user/mysql.rb | 4 ++-- lib/puppet/type/mysql_database.rb | 3 +++ lib/puppet/type/mysql_user.rb | 3 +++ 6 files changed, 19 insertions(+), 10 deletions(-) delete mode 100644 lib/facter/mysql.rb create mode 100644 lib/facter/mysql_exists.rb create mode 100644 lib/facter/mysql_version.rb (limited to 'lib') diff --git a/lib/facter/mysql.rb b/lib/facter/mysql.rb deleted file mode 100644 index e262ec1..0000000 --- a/lib/facter/mysql.rb +++ /dev/null @@ -1,8 +0,0 @@ -Facter.add("mysql_exists") do - ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin" - - setcode do - mysqlexists = system "which mysql > /dev/null 2>&1" - ($?.exitstatus == 0) - end -end diff --git a/lib/facter/mysql_exists.rb b/lib/facter/mysql_exists.rb new file mode 100644 index 0000000..d08dabe --- /dev/null +++ b/lib/facter/mysql_exists.rb @@ -0,0 +1,5 @@ +Facter.add("mysql_exists") do + setcode do + File.exist? '/usr/bin/mysql' + end +end diff --git a/lib/facter/mysql_version.rb b/lib/facter/mysql_version.rb new file mode 100644 index 0000000..ba3dc36 --- /dev/null +++ b/lib/facter/mysql_version.rb @@ -0,0 +1,6 @@ +Facter.add("mysql_version") do + confine :mysql_exists => true + setcode do + Facter::Util::Resolution.exec('mysql --version').chomp.split(' ')[4].split(',').first + end +end diff --git a/lib/puppet/provider/mysql_user/mysql.rb b/lib/puppet/provider/mysql_user/mysql.rb index e04d7e6..3051681 100644 --- a/lib/puppet/provider/mysql_user/mysql.rb +++ b/lib/puppet/provider/mysql_user/mysql.rb @@ -1,8 +1,8 @@ require 'puppet/provider/package' Puppet::Type.type(:mysql_user).provide(:mysql, - # T'is funny business, this code is quite generic - :parent => Puppet::Provider::Package) do + # T'is funny business, this code is quite generic + :parent => Puppet::Provider::Package) do desc "Use mysql as database." commands :mysql => '/usr/bin/mysql' diff --git a/lib/puppet/type/mysql_database.rb b/lib/puppet/type/mysql_database.rb index b01bb83..0ba929f 100644 --- a/lib/puppet/type/mysql_database.rb +++ b/lib/puppet/type/mysql_database.rb @@ -1,7 +1,10 @@ # This has to be a separate type to enable collecting Puppet::Type.newtype(:mysql_database) do @doc = "Manage a database." + ensurable + autorequire(:service) { 'mysql' } + newparam(:name) do desc "The name of the database." diff --git a/lib/puppet/type/mysql_user.rb b/lib/puppet/type/mysql_user.rb index 55d97b6..0b7e9af 100644 --- a/lib/puppet/type/mysql_user.rb +++ b/lib/puppet/type/mysql_user.rb @@ -1,7 +1,10 @@ # This has to be a separate type to enable collecting Puppet::Type.newtype(:mysql_user) do @doc = "Manage a database user." + ensurable + autorequire(:service) { 'mysqld' } + newparam(:name) do desc "The name of the user. This uses the 'username@hostname' form." -- cgit v1.2.3