Sha256: e7528504ec52644dfb017a81f2d0b6c3a9aacac682a0f54a646f94a3f776f191

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

# This has to be a separate type to enable collecting
Puppet::Type.newtype(:database_user) do
  @doc = 'Manage a database user. This includes management of users password as well as privileges'

  ensurable

  newparam(:name, :namevar=>true) do
    desc "The name of the user. This uses the 'username@hostname' or username@hostname."
    validate do |value|
      Puppet.warning("database has been deprecated in favor of mysql_database.")
      # https://dev.mysql.com/doc/refman/5.1/en/account-names.html
      # Regex should problably be more like this: /^[`'"]?[^`'"]*[`'"]?@[`'"]?[\w%\.]+[`'"]?$/
      raise(ArgumentError, "Invalid database user #{value}") unless value =~ /[\w-]*@[\w%\.:]+/
      username = value.split('@')[0]
      if username.size > 16
        raise ArgumentError, 'MySQL usernames are limited to a maximum of 16 characters'
      end
    end
  end

  newproperty(:password_hash) do
    desc 'The password hash of the user. Use mysql_password() for creating such a hash.'
    newvalue(/\w+/)
  end

  newproperty(:max_user_connections) do
    desc "Max concurrent connections for the user. 0 means no (or global) limit."
    newvalue(/\d+/)
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
freighthop-0.6.1 modules/mysql/lib/puppet/type/database_user.rb
freighthop-0.6.0 modules/mysql/lib/puppet/type/database_user.rb
freighthop-0.5.2 modules/mysql/lib/puppet/type/database_user.rb
freighthop-0.5.1 modules/mysql/lib/puppet/type/database_user.rb
freighthop-0.5.0 modules/mysql/lib/puppet/type/database_user.rb
freighthop-0.4.1 modules/mysql/lib/puppet/type/database_user.rb
freighthop-0.4.0 modules/mysql/lib/puppet/type/database_user.rb