Tribily/puppet-mariadb — Issue #2: rfc - parametersized classes + puppet 2.6 compat
Author: grooverdan
Created: 2011-12-09 04:54:53+00:00
State: open

Puppet 2.6 doesn't seem to support hyphens in variable names.

This is an attempt at parameterized class. It has yet to propagate to the rest of the classes.

The error I haven't fixed is:
err: /Stage[main]/Mariadb::Server/User[mysql]/uid: change from 105 to 111 failed: Could not set uid on user[mysql]: Execution of '/usr/sbin/usermod -u 111 mysql' returned 8: usermod: user mysql is currently logged in

cause1: the package installation starts the service.
cause2: the group depends on the Package which creates the group.

potential solutions:
remove group rules?
something else???

diff --git a/manifests/server.pp b/manifests/server.pp
index c414d7b..d802b0e 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -1,20 +1,24 @@
-class mariadb::server inherits mariadb::client {
+class mariadb::server( $mysqlgid = 105, $mysqldatadir = '/var/lib/mysql' ) inherits mariadb::client {
+
+
+ include apt::repo::mariadb

# make sure the proper 5.1 packages are installed
package { "mariadb-server":
- ensure => "present"
+ ensure => "present",
+ require => Class["apt::repo::mariadb"],
}

# make sure the mysql user and group exist
group { "mysql":
ensure => "present",
- gid => $::mysql-gid,
+ gid => $mysqlgid,
require => Package["mariadb-server"],
}

# data directory at /mysql/data, so
# make sure that those directories exist
- file { ["/var/lib/mysql", "/var/log/mysql", "/var/run/mysqld"]:
+ file { [$mysqldatadir, "/var/log/mysql", "/var/run/mysqld"]:
ensure => "directory",
owner => "mysql",
group => "mysql"
@@ -49,10 +53,10 @@ class mariadb::server inherits mariadb::client {

user { "mysql":
ensure => "present",
- uid => $::mysql-gid,
- gid => $::mysql-gid,
+ uid => $mysqlgid,
+ gid => $mysqlgid,
comment => "MariaDB Server",
- home => $::mysql-data-dir,
+ home => $mysqldatadir,
shell => "/bin/bash",
require => [
Package["mariadb-server"],
@@ -64,12 +68,11 @@ class mariadb::server inherits mariadb::client {
service { "mysql":
enable => true,
ensure => "running",
- #ensure => "stopped",
hasrestart => true,
hasstatus => true,
require => [
File["/etc/mysql/my.cnf"],
- File[$::mysql-data-dir],
+ File[$mysqldatadir],
Package["mariadb-server"]
],
}