aboutsummaryrefslogtreecommitdiff
path: root/manifests/subsystems/database.pp
blob: b896c013aa2eb232ae6e7cfe4a7c4a497b501ed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class database {
  include mysql::server

  # Database definitions
  define instance($password, $ensure = 'present') {
    mysql_database { "$name":
      ensure => $ensure,
    }

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

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