aboutsummaryrefslogtreecommitdiff
path: root/manifests/subsystems/database.pp
blob: 7b5398f13986ab0920ceda6656134509e3c0dd4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class database {
  include mysql::server

  # See http://www.smilecouple.org/2011/03/01/fix-out-of-resource-problem-with-mysql
  file { '/etc/security/limits.d/mysql.conf':
    ensure  => absent,
    owner   => root,
    group   => root,
    mode    => 0644,
    content => "mysql soft nofile 24000\nmysql hard nofile 32000\n",
  }

  # Database definitions
  define instance($password, $ensure = 'present', $privileges = 'all') {
    mysql_database { "$name":
      ensure  => $ensure,
      require => Service['mysql'],
    }

    mysql_user { "$name@%":
      ensure        => $ensure,
      password_hash => mysql_password($password),
      require       => Mysql_database["$name"],
    }

    if $ensure == 'present' {
      mysql_grant { "$name@%/$name":
        privileges => $privileges,
        require    => Mysql_user["$name@%"],
      }
    }
  }
}