> Hi,
>
> thank you for your interest in working on puppet!
thank you for answer ;)
> 1) You need to define mrootpw as parameter on the type, so you receive
> the value from the manifest
I try:
1. Add parameter in puppet defenition in custom type
2. Add parametr in custom class
3. Add code in provider with global ruby value (@value)
It's not work (and i'm stupid :( )
> 2) $mrootpw is not ruby
I add it in puppet defenition
> 3) putting the password on the commandline makes it public on the
> machine it is running as well as many log files. It'd be better to
> supply a --extra-defaults-file
How i may it? In irb? Or else?
New (also not work code) code is:
----!!!---plugins-----!!!!!--------
Index: mysql_grant/mysql.rb
===================================================================
--- mysql_grant/mysql.rb (revision 2995)
+++ mysql_grant/mysql.rb (revision 3002)
@@ -30,7 +30,7 @@
commands :mysqladmin => '/usr/bin/mysqladmin'
def mysql_flush
- mysqladmin "flush-privileges"
+ mysqladmin "-uroot -p"@resource[:rootpw], "flush-privileges"
end
# this parses the
@@ -58,11 +58,11 @@
name = split_name(@resource[:name])
case name[:type]
when :user
- mysql "mysql", "-e", "INSERT INTO user (host,
user) VALUES ('%s',
'%s')" % [
+ mysql "mysql", "-uroot -p"@resource[:rootpw],
"-e", "INSERT INTO
user (host, user) VALUES ('%s', '%s')" % [
name[:host], name[:user],
]
when :db
- mysql "mysql", "-e", "INSERT INTO db (host,
user, db) VALUES
('%s', '%s', '%s')" % [
+ mysql "mysql", "-uroot -p"@resource[:rootpw],
"-e", "INSERT INTO
db (host, user, db) VALUES ('%s', '%s', '%s')" % [
name[:host], name[:user], name[:db],
]
end
@@ -71,7 +71,7 @@
end
def destroy
- mysql "mysql", "-e", "REVOKE ALL ON '%s'.* FROM '%...@%s'" %
[ @resource[:privileges], @resource[:database], @resource[:name],
@resource[:host] ]
+ mysql "mysql", "-uroot -p"@resource[:rootpw], "-e", "REVOKE ALL
ON
'%s'.* FROM '%...@%s'" % [ @resource[:privileges], @resource[:database],
@resource[:name], @resource[:host] ]
end
def row_exists?
@@ -80,7 +80,7 @@
if name[:type] == :db
fields << :db
end
- not mysql( "mysql", "-NBe", 'SELECT "1" FROM %s WHERE %s' %
[ name[:type], fields.map do |f| "%s = '%s'" % [f, name[f]] end.join('
AND ')]).empty?
+ not mysql( "mysql", "-uroot -p"@resource[:rootpw], "-NBe",
'SELECT
"1" FROM %s WHERE %s' % [ name[:type], fields.map do |f| "%s = '%s'" %
[f, name[f]] end.join(' AND ')]).empty?
end
def all_privs_set?
@@ -102,9 +102,9 @@
case name[:type]
when :user
- privs = mysql "mysql", "-Be", 'select * from user where
user="%s"
and host="%s"' % [ name[:user], name[:host] ]
+ privs = mysql "mysql", "-uroot -p"@resource[:rootpw],
"-Be",
'select * from user where user="%s" and host="%s"' % [ name[:user],
name[:host] ]
when :db
- privs = mysql "mysql", "-Be", 'select * from db where
user="%s"
and host="%s" and db="%s"' % [ name[:user], name[:host], name[:db] ]
+ privs = mysql "mysql", "-uroot -p"@resource[:rootpw],
"-Be",
'select * from db where user="%s" and host="%s" and db="%s"' %
[ name[:user], name[:host], name[:db] ]
end
if privs.match(/^$/)
@@ -150,7 +150,7 @@
# puts "set:", set
stmt = stmt << set << where
- mysql "mysql", "-Be", stmt
+ mysql "mysql", "-uroot -p"@resource[:rootpw], "-Be", stmt
mysql_flush
end
end
Index: mysql_user/mysql.rb
===================================================================
--- mysql_user/mysql.rb (revision 2995)
+++ mysql_user/mysql.rb (revision 3002)
@@ -32,14 +32,14 @@
}
end
- def mysql_flush
- mysqladmin "flush-privileges"
+ def mysql_flush(mrootpw)
+ mysqladmin "-p", $mrootpw, "flush-privileges"
end
- def query
+ def query(mrootpw)
result = {}
- cmd = "#{command(:mysql)} -NBe 'select concat(user, \"@\",
host),
password from user where concat(user, \"@\", host) = \"%s\"'" %
@resource[:name]
+ cmd = "#{command(:mysql)} "-uroot -p"@resource[:rootpw], -NBe
'select concat(user, \"@\", host), password from user where
concat(user, \"@\", host) = \"%s\"'" % @resource[:name]
execpipe(cmd) do |process|
process.each do |line|
unless result.empty?
@@ -53,17 +53,17 @@
end
def create
- mysql "mysql", "-e", "create user '%s' identified by PASSWORD
'%s'"
% [ @resource[:name].sub("@", "'@'"),
@resource.should(:password_hash) ]
+ mysql "mysql", "-uroot -p"@resource[:rootpw], "-e", "create user
'%s' identified by PASSWORD '%s'" % [ @resource[:name].sub("@",
"'@'"), @resource.should(:password_hash) ]
mysql_flush
end
def destroy
- mysql "mysql", "-e", "drop user '%s'" %
@resource[:name].sub("@",
"'@'")
+ mysql "mysql", "-uroot -p"@resource[:rootpw], "-e", "drop user
'%s'" % @resource[:name].sub("@", "'@'")
mysql_flush
end
def exists?
- not mysql("mysql", "-NBe", "select '1' from user where
CONCAT(user,
'@', host) = '%s'" % @resource[:name]).empty?
+ not mysql("mysql", "-uroot -p"@resource[:rootpw], "-NBe",
"select
'1' from user where CONCAT(user, '@', host) = '%s'" %
@resource[:name]).empty?
end
def password_hash
@@ -71,7 +71,7 @@
end
def password_hash=(string)
- mysql "mysql", "-e", "SET PASSWORD FOR '%s' = '%s'" %
[ @resource[:name].sub("@", "'@'"), string ]
+ mysql "mysql", "-uroot -p"@resource[:rootpw], "-e", "SET
PASSWORD
FOR '%s' = '%s'" % [ @resource[:name].sub("@", "'@'"), string ]
mysql_flush
end
end
Index: mysql_database/mysql.rb
===================================================================
--- mysql_database/mysql.rb (revision 2995)
+++ mysql_database/mysql.rb (revision 3002)
@@ -7,7 +7,7 @@
#commands :mysqladmin => '/usr/local/bin/mysqladmin'
#commands :mysql => '/usr/local/bin/mysql'
commands :mysql => '/usr/bin/mysql'
- commands :mysqladmin => '/usr/bin/mysqladmin'
+ commands :mysqladmin => '/usr/bin/mysqladmin'
# retrieve the current set of mysql users
def self.instances
@@ -40,14 +40,14 @@
end
def create
- mysqladmin "create", @resource[:name]
+ mysqladmin "-u root -p"@resource[:rootpw], "create",
@resource[:name]
end
def destroy
- mysqladmin "-f", "drop", @resource[:name]
+ mysqladmin "-f", "-u root -p"@resource[:rootpw], "drop",
@resource[:name]
end
def exists?
- if mysql("mysql", "-NBe", "show databases").match(/
^...@resource[:name]}$/)
+ if mysql("-u root -p"@resource[:rootpw], "mysql", "-NBe", "show
databases").match(/^...@resource[:name]}$/)
true
else
false
----!!!----pliugins------!!---
----!!--manifests of puppet defenitions---!!---
define mysql::database($rpw=$mysql_rootpw, $ensure) {
if $mysql_exists == "true" {
mysql_database { $name:
ensure => $ensure,
require => File["/root/.my.cnf"],
rootpw => $rpw,
}
}
}
define mysql::rights($rpw=$mysql_rootpw, $database, $user, $password,
$host="localhost", $ensure="present", $priv="all") {
if $mysql_exists == "true" and $ensure == "present" {
mysql_user { "${us...@${host}":
password_hash => mysql_password($password),
require => File["/root/.my.cnf"],
rootpw => $rpw,
}
mysql_grant { "${us...@${host}/${database}":
privileges => $priv,
require => File["/root/.my.cnf"],
rootpw => $rpw,
}
}
}
----!!--manifests of puppet defenitions---!!---
---!!---logs of puppet on test host---!!---
Jul 5 18:47:42 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/type]/checksum) checksum changed '{mtime}Tue Jun 22 21:02:21
+0400 2010' to '{mtime}Mon Jul 05 18:38:23 +0400 2010'
Jul 5 18:47:42 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/type/mysql_database.rb]/checksum) checksum changed '{md5}
62412e643dffc7637074c06e139b306c' to '{md5}
efc943ecc167e8d8c816ad95aedce1d9'
Jul 5 18:47:42 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/type/mysql_user.rb]/checksum) checksum changed '{md5}
891c9ffb20aefbb4b33e440f2abc421c' to '{md5}
11d5879147da18b1799a23f0e90a8619'
Jul 5 18:47:42 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/type/mysql_grant.rb]/checksum) checksum changed '{md5}
fc49241017e5ff590591f830659b185e' to '{md5}
a109ef4c2aa760e0789a0def485bfeef'
Jul 5 18:47:44 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/provider/mysql_database]/checksum) checksum changed '{mtime}Thu
Jul 01 16:22:48 +0400 2010' to '{mtime}Mon Jul 05 17:57:45 +0400 2010'
Jul 5 18:47:44 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/provider/mysql_database/mysql.rb]/checksum) checksum changed
'{md5}64c884adf3be051e051330a8d84f7f33' to '{md5}
62586371690abedfd524f4605a92ff24'
Jul 5 18:47:44 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/provider/mysql_user]/checksum) checksum changed '{mtime}Thu Jul
01 16:22:51 +0400 2010' to '{mtime}Mon Jul 05 17:57:45 +0400 2010'
Jul 5 18:47:45 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/provider/mysql_user/mysql.rb]/checksum) checksum changed '{md5}
b1ca24019ff357a74d57202cbc399f33' to '{md5}
9faef5d1a719a9b4a739ae6018eebcb2'
Jul 5 18:47:45 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/provider/mysql_grant]/checksum) checksum changed '{mtime}Tue
Jun 22 21:02:29 +0400 2010' to '{mtime}Mon Jul 05 17:57:46 +0400 2010'
Jul 5 18:47:45 web-test01 puppetd[22161]: (/File[/var/lib/puppet/lib/
puppet/provider/mysql_grant/mysql.rb]/checksum) checksum changed '{md5}
a48e3c23fd8ce998096c097fc72e6c75' to '{md5}
c5f15238146a0e213b62dfb9ae6dec89'
!!!----see in this line---!!!-----
Jul 5 18:47:48 web-test01 puppetd[22161]: Could not retrieve catalog:
Invalid parameter 'rootpw' for type 'Mysql_user' at /var/lib/puppet/
modules/modules_development/mod_mysql/manifests/init.pp:336 on node
web-test01.int.ha-systems.ru
!!!----see in this line---!!!-----
---!!---logs of puppet on test host---!!---
I don't understand, what's i make wrong, becouse has small skill of
ruby. Please help me.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.