summaryrefslogtreecommitdiff
path: root/manifests/admin_user.pp
blob: 78085bc6f19e5c17d837a03a7152c33bb3e244f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# add an admin user that has
# access to all databases
define mysql::admin_user(
  $password,
  $ensure = present,
  $host = '127.0.0.1'
){
  $password_hash = $password ? {
    'trocla' => trocla("mysql_admin-user_${name}",'mysql'),
    default => $password,
  }
  mysql_user{"${name}@${host}":
    ensure        => $ensure,
    password_hash => $password_hash,
    require       => Exec['mysql_set_rootpw'],
  }
  if $ensure == 'present' {
    mysql_grant{"${name}@${host}":
      privileges  => 'all',
      require     => Mysql_user["${name}@${host}"],
    }
  }
}