summaryrefslogtreecommitdiff
path: root/manifests/config.pp
blob: 2110efc42c9928b6e8b3515f96de429fd013ddf8 (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
34
35
36
37
38
define database::config(
  $value,
  $order   = 'zz',
  $section = '',
  $ensure  = 'present'
) {
  # Guess section based on operating system and implementation
  $implementation = $::mysql::server::implementation
    $real_section = $section ? {
      '' => $implementation ? {
        'mysql-server' => $::lsbdistid ? {
          'Ubuntu' => 'mysql.conf.d',
          'Debian' => 'mariadb.conf.d',
        },
        'mariadb-server' => 'mariadb.conf.d',
      },
      default => $section,
    }

  # Old file
  file { "/etc/mysql/${real_section}/${name}.cnf":
    ensure => absent,
  }

  # Old file
  file { "/etc/mysql/conf.d/${name}.cnf":
    ensure => absent,
  }

  file { "/etc/mysql/${real_section}/${order}-${name}.cnf":
    ensure  => $ensure,
    owner   => root,
    group   => root,
    mode    => '0644',
    content => "[mysqld]\n${name} = ${value}\n",
    notify  => Service['mysql'],
  }
}