Trying to install mysql 5.6.10 from http://dev.mysql.com is a pain with puppet. One reason is that it doesn't seem to play nicely on ubuntu, in so much as the preseed options do not seem to be honored, so you have to manually set the root password! The horror!
There are also several files it installs that you definately do not want, the random my.cnf in the /opt/ directories, for example. Take note that these will be included in your config when you start up mysql! So make sure to remove them before hand
The basic puppet (version 2 - though it will also work with v3) config I have for this is:
There are also several files it installs that you definately do not want, the random my.cnf in the /opt/ directories, for example. Take note that these will be included in your config when you start up mysql! So make sure to remove them before hand
The basic puppet (version 2 - though it will also work with v3) config I have for this is:
class mysql-5-6-10 {
include accounts::users
include mysql-5-6-10::files
include mysql-5-6-10::packages
include mysql-5-6-10::symlink
include mysql-5-6-10::exec
include mysql-5-6-10::service
include mysql-5-6-10::postservice
include mysql-5-6-10::tcollector
include mysql-5-6-10::checkmk
include stats
Class['stats']->
Class['mysql-5-6-10::files']->
Class['mysql-5-6-10::packages']->
Class['mysql-5-6-10::symlink']->
Class['mysql-5-6-10::exec']->
Class['mysql-5-6-10::service']->
Class['mysql-5-6-10::postservice']->
Class['mysql-5-6-10::tcollector']->
Class['mysql-5-6-10::checkmk']
Accounts::Virtual::User::Localuser <| group == "dbas" |>
Accounts::Virtual::Group::Localgroup <| title == "dbas" |>
Accounts::Virtual::User::Localuser <| group == "mysql"|>
Accounts::Virtual::Group::Localgroup <| title == "mysql" |>
nagios::checkmk::addtag { 'mysql': }
}
#############################
# Mysql 5.6 specific options
# requires conf.d directory
file { '/etc/mysql/conf.d':
ensure => directory,
mode => 0775,
owner => root,
}
# add data dir
file { '/var/lib/mysql':
ensure => directory,
mode => 0755,
owner => mysql,
group => mysql,
}
# Add init script symlink:
file { '/etc/init.d/mysql':
source => 'puppet:///mysql-5-6-10/init.d/mysql',
owner => root,
group => root,
mode => 0755,
}
# needed for logs
file {'/var/log/mysql':
ensure => directory,
owner => 'mysql',
group => 'mysql',
mode => 0755,
}
# wipe the stuff that doesn't need to be there or it might conflict with what we're running
# wipe the default config so it doesn't load ita and override our confi
file { '/opt/mysql/server-5.6/support-files/my-default.cnf':
ensure => absent,
#ensure => link,
#target => '/etc/mysql/my.cnf',
}
file { '/opt/mysql/server-5.6/data':
ensure => absent,
}
class mysql-5-6-10::packages {
$mysql_server_package = 'mysql'
$generic_packages = [
'libaio1',
]
package { 'mysql-server-package-5-6-10':
name => $mysql_server_package,
ensure => installed,
responsefile => '/etc/mysql/mysql_preseed',
}
package { 'mysql-support-packages-5-6-10':
name => $generic_packages,
ensure => installed,
before => Package['mysql-server-package-5-6-10'],
}
}
class mysql-5-6-10::symlink {
#requires sym linking
file {'/usr/bin/innochecksum': ensure => link, target => '/opt/mysql/server-5.6/bin/innochecksum',}
file {'/usr/bin/msql2mysql': ensure => link, target => '/opt/mysql/server-5.6/bin/msql2mysql',}
file {'/usr/bin/myisamchk': ensure => link, target => '/opt/mysql/server-5.6/bin/myisamchk',}
file {'/usr/bin/myisam_ftdump': ensure => link, target => '/opt/mysql/server-5.6/bin/myisam_ftdump',}
file {'/usr/bin/myisamlog': ensure => link, target => '/opt/mysql/server-5.6/bin/myisamlog',}
file {'/usr/bin/myisampack': ensure => link, target => '/opt/mysql/server-5.6/bin/myisampack',}
file {'/usr/bin/my_print_defaults': ensure => link, target => '/opt/mysql/server-5.6/bin/my_print_defaults',}
file {'/usr/bin/mysql': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql',}
file {'/usr/bin/mysqlaccess': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqlaccess',}
file {'/usr/bin/mysqlaccess.conf': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqlaccess.conf',}
file {'/usr/bin/mysqladmin': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqladmin',}
file {'/usr/bin/mysqlbinlog': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqlbinlog',}
file {'/usr/bin/mysqlbug': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqlbug',}
file {'/usr/bin/mysqlcheck': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqlcheck',}
file {'/usr/bin/mysql_client_test': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_client_test',}
file {'/usr/bin/mysql_client_test_embedded': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_client_test_embedded',}
file {'/usr/bin/mysql_config': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_config',}
file {'/usr/bin/mysql_config_editor': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_config_editor',}
file {'/usr/bin/mysql_convert_table_format': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_convert_table_format',}
file {'/usr/bin/mysqld': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqld',}
file {'/usr/bin/mysqld-debug': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqld-debug',}
file {'/usr/bin/mysqld_multi': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqld_multi',}
file {'/usr/bin/mysqld_safe': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqld_safe',}
file {'/usr/bin/mysqldump': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqldump',}
file {'/usr/bin/mysqldumpslow': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqldumpslow',}
file {'/usr/bin/mysql_embedded': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_embedded',}
file {'/usr/bin/mysql_find_rows': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_find_rows',}
file {'/usr/bin/mysql_fix_extensions': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_fix_extensions',}
file {'/usr/bin/mysqlhotcopy': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqlhotcopy',}
file {'/usr/bin/mysqlimport': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqlimport',}
file {'/usr/bin/mysql_plugin': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_plugin',}
file {'/usr/bin/mysql_secure_installation': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_secure_installation',}
file {'/usr/bin/mysql_setpermission': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_setpermission',}
file {'/usr/bin/mysqlshow': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqlshow',}
file {'/usr/bin/mysqlslap': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqlslap',}
file {'/usr/bin/mysqltest': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqltest',}
file {'/usr/bin/mysqltest_embedded': ensure => link, target => '/opt/mysql/server-5.6/bin/mysqltest_embedded',}
file {'/usr/bin/mysql_tzinfo_to_sql': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_tzinfo_to_sql',}
file {'/usr/bin/mysql_upgrade': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_upgrade',}
file {'/usr/bin/mysql_waitpid': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_waitpid',}
file {'/usr/bin/mysql_zap': ensure => link, target => '/opt/mysql/server-5.6/bin/mysql_zap',}
file {'/usr/bin/perror': ensure => link, target => '/opt/mysql/server-5.6/bin/perror',}
file {'/usr/bin/replace': ensure => link, target => '/opt/mysql/server-5.6/bin/replace',}
file {'/usr/bin/resolveip': ensure => link, target => '/opt/mysql/server-5.6/bin/resolveip',}
file {'/usr/bin/resolve_stack_dump': ensure => link, target => '/opt/mysql/server-5.6/bin/resolve_stack_dump',}
}
class mysql-5-6-10::exec {
# this only needs to be run once
exec {'mysql_create_datadir-5-6-10':
command => "/opt/mysql/server-5.6/scripts/mysql_install_db --basedir=/opt/mysql/server-5.6/ --datadir=/var/lib/mysql/ --user=mysql ",
refreshonly => true,
subscribe => File['/usr/bin/mysql'],
}
exec {'mysql_updatercd':
command => "/usr/sbin/update-rc.d mysql start 40 2 3 4 5 . stop 40 0 1 6 .",
refreshonly => true,
subscribe => Exec['mysql_create_datadir-5-6-10'],
}
}
class mysql-5-6-10::service {
service { 'mysql':
ensure => running,
hasstatus => true,
hasrestart => true,
}
}
class mysql-5-6-10::postservice {
$mysql_root_password = hiera('mysql_root_password')
# Set root password cos pre-seed doesn't work
exec {'mysql_setrootpasswd':
command => "/usr/bin/mysqladmin -uroot password $mysql_root_password",
creates => "/etc/mysql/.mysql_setroot",
}
#this only needs to be run once - done at livedata_local setup
exec {'mysql_create_tables-5-6-10':
command => "/usr/bin/mysql < /etc/mysql/LiveData_Local.sql ",
refreshonly => true,
subscribe => Exec['mysql_setrootpasswd'],
}
}
This is pretty self explainatory.
We use hiera to store passwords, and there is a refresh on the exec, as we only want to run the command once.
We also setup the database and user accounts with the 'mysql_create_tables' exec
No comments:
Post a Comment