Skip to content

Commit

Permalink
Mysql depcycle (#73)
Browse files Browse the repository at this point in the history
* Fix linting issue in firewall class

* Accommodate upstream ordering changes

::mysql::server::config is now before install, so a bunch of things
needed to be moved around to prevent dependency cycles. In addition,
since galera generally won't start without being bootstrapped, debians
require some additional effort to have the default config applied
when the package installs (and starts the service by default) but
the real config applied when the service is started by the module.
  • Loading branch information
michaeltchapman authored Jul 12, 2016
1 parent 6c43cbc commit a9c6bce
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 15 deletions.
5 changes: 3 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Change this to swap between a centos and an ubuntu box
box = 'puppetlabs/centos-7.0-64-puppet'
#box = 'trusty64'

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Expand All @@ -21,7 +22,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
'ln -s /vagrant /etc/puppet/modules/galera'
end

if box == 'precise64'
if box == 'precise64' or box == 'trusty64'
control1.vm.provision :shell do |shell|
script =
"if grep 127.0.1.1 /etc/hosts ; then \n" +
Expand Down Expand Up @@ -81,7 +82,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
'ln -s /vagrant /etc/puppet/modules/galera'
end

if box == 'precise64'
if box == 'precise64' or box == 'trusty64'
control2.vm.provision :shell do |shell|
script =
"if grep 127.0.1.1 /etc/hosts ; then \n" +
Expand Down
2 changes: 1 addition & 1 deletion examples/centos7.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
galera_master => 'control1.domain.name',
vendor_type => 'mariadb',
status_password => 'mariadb',
bind_address => $::ipaddress_enp0s8
bind_address => $::ipaddress_enp0s8,
}
}
29 changes: 28 additions & 1 deletion manifests/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@
warn('the galera::debian class has been included on a non-debian host')
}

# puppetlabs-mysql now places config before installing the package, which causes issues
# if the service is started as part of package installs, as it is on debians. Resolve this
# by putting a default my.cnf in place before installing the package, then putting the
# real config file back after installing the package but before starting the service for real
file { '/etc/mysql/puppet_debfix.cnf':
ensure => present,
owner => 'root',
group => 'root',
content => template('galera/debian_default_my_cnf'),
require => Class['mysql::server::config'],
} ~>

exec { 'fix_galera_config_errors_episode_I':
command => 'mv -f /etc/mysql/my.cnf /tmp/my.cnf && cp -f /etc/mysql/puppet_debfix.cnf /etc/mysql/my.cnf',
path => '/usr/bin:/bin:/usr/sbin:/sbin',
refreshonly => true,
} ~>

exec { 'fix_galera_config_errors_episode_II':
command => 'cp -f /tmp/my.cnf /etc/mysql/my.cnf',
path => '/usr/bin:/bin:/usr/sbin:/sbin',
refreshonly => true,
require => Class['mysql::server::install'],
before => Class['mysql::server::installdb'],
}


# Debian policy will autostart the non galera mysql after
# package install, so kill it if the package is
# installed during this puppet run
Expand All @@ -16,7 +43,7 @@
path => '/usr/bin:/bin:/usr/sbin:/sbin',
refreshonly => true,
subscribe => Package['mysql-server'],
before => Class['mysql::server::config'],
before => Class['mysql::server::installdb'],
require => Class['mysql::server::install'],
}

Expand Down
18 changes: 9 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@
"/usr/bin/mysql --user=root --password=${root_password} -e 'select count(1);'",
"/usr/bin/test `/bin/cat ${::root_home}/.my.cnf | /bin/grep -c \"password='${root_password}'\"` -eq 0",
],
require => [Service['mysqld']],
require => Service['mysqld'],
before => [Class['mysql::server::root_password']],
}
}

class { 'mysql::server':
class { '::mysql::server':
package_name => $galera::params::mysql_package_name,
override_options => $options,
root_password => $root_password,
Expand All @@ -227,15 +227,15 @@
owner => 'mysql',
group => 'mysql',
require => Class['mysql::server::install'],
before => Class['mysql::server::config']
before => Class['mysql::server::installdb']
}

if $galera::params::additional_packages {
ensure_resource(package, $galera::params::additional_packages,
{
ensure => $package_ensure,
require => Anchor['mysql::server::start'],
before => Class['mysql::server::install']
before => Class['mysql::server::install'],
require => Class['mysql::server::config']
})
}

Expand All @@ -247,8 +247,8 @@
$galera::params::galera_package_name,
] :
ensure => $package_ensure,
require => Anchor['mysql::server::start'],
before => Class['mysql::server::install']
before => Class['mysql::server::install'],
require => Class['mysql::server::config']
}


Expand All @@ -267,8 +267,8 @@
exec { 'bootstrap_galera_cluster':
command => $galera::params::bootstrap_command,
unless => "nmap -p ${wsrep_group_comm_port} ${server_list} | grep -q '${wsrep_group_comm_port}/tcp open'",
require => [Class['mysql::server::config'],Class['mysql::server::installdb']],
before => [Class['mysql::server::service'], Service['mysqld']],
require => Class['mysql::server::installdb'],
before => Service['mysqld'],
provider => shell,
path => '/usr/bin:/bin:/usr/sbin:/sbin'
}
Expand Down
4 changes: 2 additions & 2 deletions manifests/mariadb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
if versioncmp($::operatingsystemmajrelease, '7') >=0 {
file { '/var/log/mariadb':
ensure => 'directory',
before => Class['mysql::server::config'],
before => Class['mysql::server::install'],
}

file { '/var/run/mariadb':
ensure => 'directory',
owner => 'mysql',
group => 'mysql',
require => Class['mysql::server::install'],
before => Class['mysql::server::config'],
before => Class['mysql::server::installdb'],
}
}
}
69 changes: 69 additions & 0 deletions templates/debian_default_my_cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock


[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc_messages_dir = /usr/share/mysql
lc_messages = en_US
skip-external-locking
bind-address = 127.0.0.1
max_connections = 100
connect_timeout = 5
wait_timeout = 600
max_allowed_packet = 16M
thread_cache_size = 128
sort_buffer_size = 4M
bulk_insert_buffer_size = 16M
tmp_table_size = 32M
max_heap_table_size = 32M
myisam_recover = BACKUP
key_buffer_size = 128M
table_open_cache = 400
myisam_sort_buffer_size = 512M
concurrent_insert = 2
read_buffer_size = 2M
read_rnd_buffer_size = 1M
query_cache_limit = 128K
query_cache_size = 64M
log_warnings = 2
slow_query_log_file = /var/log/mysql/mariadb-slow.log
long_query_time = 10
log_slow_verbosity = query_plan

log_bin = /var/log/mysql/mariadb-bin
log_bin_index = /var/log/mysql/mariadb-bin.index
expire_logs_days = 10
max_binlog_size = 100M
default_storage_engine = InnoDB
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 8M
innodb_file_per_table = 1
innodb_open_files = 400
innodb_io_capacity = 400
innodb_flush_method = O_DIRECT



[mysqldump]
quick
quote-names
max_allowed_packet = 16M

[mysql]

[isamchk]
key_buffer = 16M

!includedir /etc/mysql/conf.d/

0 comments on commit a9c6bce

Please sign in to comment.