Hi,

I'm using duritong's puppet module and I've run into a bizarre issue after
migrating to it that I cannot resolve and I thought I'd take it to the list
in the hope someone can help.

The error I get from a run is:

info: Retrieving plugin
info: Loading facts in dell
info: Loading facts in apache-ports
info: Loading facts in mysql
info: Loading facts in location
info: Loading facts in convera
info: Loading facts in dell
info: Loading facts in apache-portsinfo: Loading facts in mysql
info: Loading facts in location
info: Loading facts in convera
info: Caching catalog for hlstestidm1.law.harvard.edu
err: Could not run Puppet configuration client: Invalid parameter defaults
at
/etc/puppet/modules/development/mysql/manifests/server/account_security.pp:12

That file is:

--------

class mysql::server::account_security {
   # some installations have some default users which are not required.
   # We remove them here. You can subclass this class to overwrite this
behavior.
   #mysql_user{ [ "root@${fqdn}", "root@127.0.0.1", "@${fqdn}",
"@localhost", "@%" ]:
     #ensure => absent,
   #  require => Service['mysqld'],
   #}

        mysql_user { "root@${fqdn}":
                ensure => absent,
                require => Service['mysqld'],
        }

}

--------

I think the issue is something to do with mysql_user not allowing ensure to
be used, but the error message doesn't really help.  Running puppetd -tvd
didn't add any extra information to help me nail this down.

For reference the mysql_user type is:

----------

# This has to be a separate type to enable collecting
Puppet::Type.newtype(:mysql_user) do
  @doc = "Manage a database user."
  ensurable
  newparam(:name) do
    desc "The name of the user. This uses the 'username@hostname' form."

    validate do |value|
      if value.split('@').first.size > 16
        raise ArgumentError,
              "MySQL usernames are limited to a maximum of 16 characters"
      else
        super
      end
    end
  end

  newproperty(:password_hash) do
    desc "The password hash of the user. Use mysql_password() for creating
such a hash."
  end
end

-------

and the provider for mysql_user:

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

        desc "Use mysql as database."
        commands :mysql => '/usr/bin/mysql'
        commands :mysqladmin => '/usr/bin/mysqladmin'

        # retrieve the current set of mysql users
        def self.instances
                users = []

                cmd = "#{command(:mysql)} mysql -NBe 'select concat(user,
\"@\", host), password from user'"
                execpipe(cmd) do |process|
                        process.each do |line|
                                users << new( query_line_to_hash(line) )
                        end
                end
                return users
        end

        def self.query_line_to_hash(line)
                fields = line.chomp.split(/\t/)
                {
                        :name => fields[0],
                        :password_hash => fields[1],
                        :ensure => :present
                }
        end

        def mysql_flush
                mysqladmin "flush-privileges"
        end

        def query
                result = {}

                cmd = "#{command(:mysql)} -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?
                                        raise Puppet::Error,
                                                "Got multiple results for
user '%s'" % @resource[:name]
                                end
                                result = query_line_to_hash(line)
                        end
                end
                result
        end

        def create
                mysql "mysql", "-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_flush
        end

        def exists?
                not mysql("mysql", "-NBe", "select '1' from user where
CONCAT(user, '@', host) = '%s'" % @resource[:name]).empty?
        end

        def password_hash
                @property_hash[:password_hash]
        end

        def password_hash=(string)
                mysql "mysql", "-e", "SET PASSWORD FOR '%s' = '%s'" % [
@resource[:name].sub("@", "'@'"), string ]
                mysql_flush
        end
end

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to