view modules/website/manifests/mysql.pp @ 7:3523e4c2604c

Disable slow query logging - it got quite large and needs looking at!
author IBBoard <dev@ibboard.co.uk>
date Wed, 08 Oct 2014 19:45:21 +0000
parents f2056be70cb8
children aa40b53324e4 62ae90b291b3
line wrap: on
line source

class website::mysql (
  $mysqluser,
  $mysqlpassword,
  $mysqlsuffix    = '',
  $phpsuffix      = '',
  $phpmysqlsuffix = '')
  {
  class { 'mysql::client':
    package_name    => "mysql${mysqlsuffix}",
    bindings_enable => false, #Deal with bindings manually
  }
  class { 'mysql::bindings':
    php_enable       => true,
    php_package_name => "php${phpsuffix}-mysql${phpmysqlsuffix}",
  }
  class { 'mysql::server':
    package_name => "mysql${mysqlsuffix}-server",
    override_options => {
      'mysqld' => {
        'query_cache_size' => '32M',
        'join_buffer_size' => '524288', #512K
        'tmp_table_size'   => '64M',
        'max_heap_table_size' => '64M',
        'table_open_cache' => '500',
        'log-queries-not-using-indexes' => '1',
      }
    },
    require => File['/var/log/mysql/']
  }
  file { '/var/log/mysql':
    ensure => directory,
    owner => 'mysql',
    group => 'mysql',
  }
  $username = strip($mysqluser)
  $password = strip($mysqlpassword)
  $configured_marker = '/etc/mysql/.is-configured'
  exec { 'Rename root MySQL user for security':
    command  => "mysql -uroot -e 'UPDATE mysql.user SET User = \"$username\", Password = PASSWORD(\"$password\") WHERE User = \"root\"; DELETE FROM mysql.user WHERE User = ''; FLUSH PRIVILEGES;' && touch $configured_marker",
    provider => shell,
    creates  => $configured_marker
  }
}