diff --git a/deployment/puppet/mysql/manifests/config.pp b/deployment/puppet/mysql/manifests/config.pp index 600d62e6cc..d7be171c49 100644 --- a/deployment/puppet/mysql/manifests/config.pp +++ b/deployment/puppet/mysql/manifests/config.pp @@ -11,10 +11,11 @@ # [*config_file*] - my.cnf configuration file path. # [*socket*] - mysql socket. # [*datadir*] - path to datadir. -# [*ssl] - enable ssl -# [*ssl_ca] - path to ssl-ca -# [*ssl_cert] - path to ssl-cert -# [*ssl_key] - path to ssl-key +# [*ssl*] - enable ssl +# [*ssl_ca*] - path to ssl-ca +# [*ssl_cert*] - path to ssl-cert +# [*ssl_key*] - path to ssl-key +# [*ignore_db_dirs*] - array of directories to ignore in datadir. # # Actions: # @@ -49,6 +50,7 @@ class mysql::config( $server_id = $mysql::params::server_id, $debug = $mysql::params::debug, $wait_timeout = $mysql::params::wait_timeout, + $ignore_db_dirs = $mysql::params::ignore_db_dirs, ) inherits mysql::params { $mysql_buffer_pool_size = $::mysql::params::mysql_buffer_pool_size @@ -59,6 +61,10 @@ class mysql::config( $myisam_sort_buffer_size = $::mysql::params::myisam_sort_buffer_size $open_files_limit = $::mysql::params::open_files_limit + if ! is_array($ignore_db_dirs) { + fail('The ignore_db_dirs parameter is expected to be an array') + } + if $custom_setup_class != "pacemaker_mysql" { File { owner => 'root', diff --git a/deployment/puppet/mysql/manifests/params.pp b/deployment/puppet/mysql/manifests/params.pp index 288d92e279..a419a7f7f9 100644 --- a/deployment/puppet/mysql/manifests/params.pp +++ b/deployment/puppet/mysql/manifests/params.pp @@ -32,6 +32,7 @@ class mysql::params { $open_files_limit = '102400' $max_connections = '3000' $debug = false + $ignore_db_dirs = [] case $::osfamily { 'RedHat': { diff --git a/deployment/puppet/mysql/manifests/server.pp b/deployment/puppet/mysql/manifests/server.pp index 208e9513e3..4cce092865 100644 --- a/deployment/puppet/mysql/manifests/server.pp +++ b/deployment/puppet/mysql/manifests/server.pp @@ -41,6 +41,7 @@ class mysql::server ( $bind_address = '0.0.0.0', $use_syslog = true, $wait_timeout = $mysql::params::wait_timeout, + $ignore_db_dirs = $mysql::params::ignore_db_dirs, ) inherits mysql::params { if ($config_hash['config_file']) { diff --git a/deployment/puppet/mysql/templates/my.cnf.erb b/deployment/puppet/mysql/templates/my.cnf.erb index 1839cc1ccc..a88489ca79 100644 --- a/deployment/puppet/mysql/templates/my.cnf.erb +++ b/deployment/puppet/mysql/templates/my.cnf.erb @@ -22,6 +22,11 @@ port = <%= @port %> basedir = <%= @basedir %> datadir = <%= @datadir %> tmpdir = /tmp +<% if @ignore_db_dirs and (@ignore_db_dirs.length > 0) %> + <% @ignore_db_dirs.each do |directory| %> +ignore-db-dir = <%= directory %> + <% end %> +<% end %> skip-external-locking bind-address = <%= @bind_address %> max_allowed_packet = 256M diff --git a/deployment/puppet/osnailyfacter/modular/database/database.pp b/deployment/puppet/osnailyfacter/modular/database/database.pp index 02a1e6c80b..811bcc37d6 100644 --- a/deployment/puppet/osnailyfacter/modular/database/database.pp +++ b/deployment/puppet/osnailyfacter/modular/database/database.pp @@ -53,6 +53,12 @@ if $enabled { $config_hash_real = { } } + if '/var/lib/mysql' in split($::mounts, ',') { + $ignore_db_dirs = ['lost+found'] + } else { + $ignore_db_dirs = [] + } + class { 'mysql::server': bind_address => '0.0.0.0', etc_root_password => true, @@ -68,6 +74,7 @@ if $enabled { mysql_skip_name_resolve => $mysql_skip_name_resolve, use_syslog => $use_syslog, config_hash => $config_hash_real, + ignore_db_dirs => $ignore_db_dirs, } class { 'osnailyfacter::mysql_user': diff --git a/tests/noop/spec/hosts/database/database_spec.rb b/tests/noop/spec/hosts/database/database_spec.rb index 19f1ee532b..3dec2d262e 100644 --- a/tests/noop/spec/hosts/database/database_spec.rb +++ b/tests/noop/spec/hosts/database/database_spec.rb @@ -4,6 +4,12 @@ manifest = 'database/database.pp' describe manifest do shared_examples 'catalog' do + let(:facts) { + Noop.ubuntu_facts.merge({ + :mounts => '/,/boot,/var/log,/var/lib/glance,/var/lib/mysql' + }) + } + let(:endpoints) do Noop.hiera('network_scheme', {}).fetch('endpoints', {}) end @@ -24,7 +30,7 @@ describe manifest do (Noop.puppet_function 'get_node_to_ipaddr_map_by_network_role', database_nodes, 'mgmt/database').values end - it "should delcare osnailyfacter::mysql_user with correct other_networks" do + it "should declare osnailyfacter::mysql_user with correct other_networks" do expect(subject).to contain_class('osnailyfacter::mysql_user').with( 'user' => 'root', 'access_networks' => access_networks, @@ -37,6 +43,12 @@ describe manifest do ).that_comes_before('Osnailyfacter::Mysql_user') end + it "should configure mysql to ignore lost+found directory" do + expect(subject).to contain_class('mysql::server').with( + 'ignore_db_dirs' => ['lost+found'] + ).that_comes_before('Osnailyfacter::Mysql_user') + end + it { should contain_class('osnailyfacter::mysql_access') } it { should contain_class('openstack::galera::status').that_comes_before('Haproxy_backend_status[mysql]') } it { should contain_haproxy_backend_status('mysql').that_comes_before('Class[osnailyfacter::mysql_access]') }