summaryrefslogtreecommitdiff
path: root/lib/puppet/type/mysql_user.rb
blob: 7d4189073c2079d6178fc74890d050c60286b16f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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."

    validate do |value|
      if value.split('@').first.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."
  end
end