diff options
Diffstat (limited to 'plugins/puppet')
-rw-r--r-- | plugins/puppet/type/mysql_user.rb | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/plugins/puppet/type/mysql_user.rb b/plugins/puppet/type/mysql_user.rb index d92b610..55d97b6 100644 --- a/plugins/puppet/type/mysql_user.rb +++ b/plugins/puppet/type/mysql_user.rb @@ -1,12 +1,22 @@ # 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." - end - newproperty(:password_hash) do - desc "The password hash of the user. Use mysql_password() for creating such a hash." - end + @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 |