diff --git a/manifests/compute.pp b/manifests/compute.pp index f39180a1..73a54c0a 100644 --- a/manifests/compute.pp +++ b/manifests/compute.pp @@ -91,4 +91,15 @@ class cloud::compute( 'DEFAULT/resume_guests_state_on_host_boot': value => true; } + # Note(EmilienM): + # We check if DB tables are created, if not we populate Nova DB. + # It's a hack to fit with our setup where we run MySQL/Galera + # TODO(Gonéri) + # We have to do this only on the primary node of the galera cluster to avoid race condition + # https://github.com/enovance/puppet-cloud/issues/156 + exec {'nova_db_sync': + command => '/usr/bin/nova-manage db sync', + unless => "/usr/bin/mysql nova -h ${nova_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables" + } + } diff --git a/manifests/database/sql.pp b/manifests/database/sql.pp index 58d50e7f..d7c9301e 100644 --- a/manifests/database/sql.pp +++ b/manifests/database/sql.pp @@ -225,6 +225,11 @@ class cloud::database::sql ( privileges => ['all'] } + + # TODO(Gonéri): + # Here we should do the db_sync. + # https://github.com/enovance/puppet-cloud/issues/156 + Database_user<<| |>> } # if $::hostname == $galera_master diff --git a/manifests/identity.pp b/manifests/identity.pp index 9ed71138..40e20239 100644 --- a/manifests/identity.pp +++ b/manifests/identity.pp @@ -525,6 +525,16 @@ class cloud::identity ( password => $ks_heat_password } + # Note(EmilienM): + # We check if DB tables are created, if not we populate Keystone DB. + # It's a hack to fit with our setup where we run MySQL/Galera + # TODO(Gonéri) + # We have to do this only on the primary node of the galera cluster to avoid race condition + # https://github.com/enovance/puppet-cloud/issues/156 + exec {'keystone_db_sync': + command => '/usr/bin/keystone-manage db_sync', + unless => "/usr/bin/mysql keystone -h ${keystone_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables" + } @@haproxy::balancermember{"${::fqdn}-keystone_api": listening_service => 'keystone_api_cluster', diff --git a/manifests/image.pp b/manifests/image.pp index aa7d1cb4..7b00d7db 100644 --- a/manifests/image.pp +++ b/manifests/image.pp @@ -126,6 +126,17 @@ class cloud::image( class { 'glance::cache::cleaner': } class { 'glance::cache::pruner': } + # Note(EmilienM): + # We check if DB tables are created, if not we populate Glance DB. + # It's a hack to fit with our setup where we run MySQL/Galera + # TODO(Gonéri) + # We have to do this only on the primary node of the galera cluster to avoid race condition + # https://github.com/enovance/puppet-cloud/issues/156 + exec {'glance_db_sync': + command => '/usr/bin/glance-manage db_sync', + unless => "/usr/bin/mysql glance -h ${glance_db_host} -u ${encoded_glance_user} -p${encoded_glance_password} -e \"show tables\" | /bin/grep Tables" + } + # TODO(EmilienM) For later, I'll also add internal network support in HAproxy for all OpenStack API, to optimize North / South network traffic @@haproxy::balancermember{"${::fqdn}-glance_api": listening_service => 'glance_api_cluster', diff --git a/manifests/network/controller.pp b/manifests/network/controller.pp index 2e75c15e..f973965b 100644 --- a/manifests/network/controller.pp +++ b/manifests/network/controller.pp @@ -38,10 +38,21 @@ class cloud::network::controller( auth_password => $ks_neutron_password, auth_host => $ks_keystone_admin_host, auth_port => $ks_keystone_public_port, + # TODO(EmilienM) This one should work, but it's the case now. Don't drop it. connection => "mysql://${encoded_user}:${encoded_password}@${neutron_db_host}/neutron?charset=utf8", + # TODO(EmilienM) Should be deprecated - bug GH#152 + sql_connection => "mysql://${encoded_user}:${encoded_password}@${neutron_db_host}/neutron?charset=utf8", api_workers => $::processorcount } + # Note(EmilienM): + # We check if DB tables are created, if not we populate Neutron DB. + # It's a hack to fit with our setup where we run MySQL/Galera + exec {'neutron_db_sync': + command => '/usr/bin/neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head', + unless => "/usr/bin/mysql neutron -h ${neutron_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables" + } + @@haproxy::balancermember{"${::fqdn}-neutron_api": listening_service => 'neutron_api_cluster', server_names => $::hostname, diff --git a/manifests/orchestration.pp b/manifests/orchestration.pp index 44bf588c..c01cb79e 100644 --- a/manifests/orchestration.pp +++ b/manifests/orchestration.pp @@ -52,4 +52,15 @@ class cloud::orchestration( debug => $debug, } + # Note(EmilienM): + # We check if DB tables are created, if not we populate Heat DB. + # It's a hack to fit with our setup where we run MySQL/Galera + # TODO(Gonéri) + # We have to do this only on the primary node of the galera cluster to avoid race condition + # https://github.com/enovance/puppet-cloud/issues/156 + exec {'heat_db_sync': + command => '/usr/bin/heat-manage --config-file /etc/heat/heat.conf db_sync', + unless => "/usr/bin/mysql heat -h ${heat_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables" + } + } diff --git a/manifests/volume.pp b/manifests/volume.pp index 3fe3cccb..ce209b4c 100644 --- a/manifests/volume.pp +++ b/manifests/volume.pp @@ -46,4 +46,15 @@ class cloud::volume( class { 'cinder::ceilometer': } + # Note(EmilienM): + # We check if DB tables are created, if not we populate Cinder DB. + # It's a hack to fit with our setup where we run MySQL/Galera + # TODO(Gonéri) + # We have to do this only on the primary node of the galera cluster to avoid race condition + # https://github.com/enovance/puppet-cloud/issues/156 + exec {'cinder_db_sync': + command => '/usr/bin/cinder-manage db sync', + unless => "/usr/bin/mysql cinder -h ${cinder_db_host} -u ${encoded_user} -p${encoded_password} -e \"show tables\" | /bin/grep Tables" + } + } diff --git a/spec/classes/cloud_compute_controller_spec.rb b/spec/classes/cloud_compute_controller_spec.rb index b656c6c5..73ca45c0 100644 --- a/spec/classes/cloud_compute_controller_spec.rb +++ b/spec/classes/cloud_compute_controller_spec.rb @@ -60,6 +60,13 @@ describe 'cloud::compute::controller' do should contain_nova_config('DEFAULT/resume_guests_state_on_host_boot').with('value' => true) end + it 'checks if Nova DB is populated' do + should contain_exec('nova_db_sync').with( + :command => '/usr/bin/nova-manage db sync', + :unless => '/usr/bin/mysql nova -h 10.0.0.1 -u nova -psecrete -e "show tables" | /bin/grep Tables' + ) + end + it 'configure nova-scheduler' do should contain_class('nova::scheduler').with(:enabled => true) end diff --git a/spec/classes/cloud_compute_hypervisor_spec.rb b/spec/classes/cloud_compute_hypervisor_spec.rb index 94d26c86..ba24e17b 100644 --- a/spec/classes/cloud_compute_hypervisor_spec.rb +++ b/spec/classes/cloud_compute_hypervisor_spec.rb @@ -59,6 +59,13 @@ describe 'cloud::compute::hypervisor' do should contain_nova_config('DEFAULT/resume_guests_state_on_host_boot').with('value' => true) end + it 'checks if Nova DB is populated' do + should contain_exec('nova_db_sync').with( + :command => '/usr/bin/nova-manage db sync', + :unless => '/usr/bin/mysql nova -h 10.0.0.1 -u nova -psecrete -e "show tables" | /bin/grep Tables' + ) + end + it 'insert and activate nbd module' do should contain_exec('insert_module_nbd').with('command' => '/bin/echo "nbd" > /etc/modules', 'unless' => '/bin/grep "nbd" /etc/modules') should contain_exec('/sbin/modprobe nbd').with('unless' => '/bin/grep -q "^nbd " "/proc/modules"') diff --git a/spec/classes/cloud_identity_spec.rb b/spec/classes/cloud_identity_spec.rb index 1c8536a3..f8f5f42b 100644 --- a/spec/classes/cloud_identity_spec.rb +++ b/spec/classes/cloud_identity_spec.rb @@ -110,6 +110,13 @@ describe 'cloud::identity' do should contain_keystone_config('ec2/driver').with('value' => 'keystone.contrib.ec2.backends.sql.Ec2') end + it 'checks if Keystone DB is populated' do + should contain_exec('keystone_db_sync').with( + :command => '/usr/bin/keystone-manage db_sync', + :unless => '/usr/bin/mysql keystone -h 10.0.0.1 -u keystone -psecrete -e "show tables" | /bin/grep Tables' + ) + end + it 'configure keystone admin role' do should contain_class('keystone::roles::admin').with( :email => 'admin@openstack.org', diff --git a/spec/classes/cloud_image_spec.rb b/spec/classes/cloud_image_spec.rb index 9dce90f0..1d9d1833 100644 --- a/spec/classes/cloud_image_spec.rb +++ b/spec/classes/cloud_image_spec.rb @@ -95,6 +95,12 @@ describe 'cloud::image' do should contain_class('glance::cache::pruner') end + it 'checks if Glance DB is populated' do + should contain_exec('glance_db_sync').with( + :command => '/usr/bin/glance-manage db_sync', + :unless => '/usr/bin/mysql glance -h 10.0.0.1 -u glance -psecrete -e "show tables" | /bin/grep Tables' + ) + end end context 'on Debian platforms' do diff --git a/spec/classes/cloud_network_controller_spec.rb b/spec/classes/cloud_network_controller_spec.rb index 024448f8..7c6886e0 100644 --- a/spec/classes/cloud_network_controller_spec.rb +++ b/spec/classes/cloud_network_controller_spec.rb @@ -72,13 +72,22 @@ describe 'cloud::network::controller' do it 'configure neutron server' do should contain_class('neutron::server').with( - :auth_password => 'secrete', - :auth_host => '10.0.0.1', - :auth_port => '5000', - :connection => 'mysql://neutron:secrete@10.0.0.1/neutron?charset=utf8', - :api_workers => '2' + :auth_password => 'secrete', + :auth_host => '10.0.0.1', + :auth_port => '5000', + :connection => 'mysql://neutron:secrete@10.0.0.1/neutron?charset=utf8', + :sql_connection => 'mysql://neutron:secrete@10.0.0.1/neutron?charset=utf8', + :api_workers => '2' ) end + + it 'checks if Neutron DB is populated' do + should contain_exec('neutron_db_sync').with( + :command => '/usr/bin/neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head', + :unless => '/usr/bin/mysql neutron -h 10.0.0.1 -u neutron -psecrete -e "show tables" | /bin/grep Tables' + ) + end + end context 'on Debian platforms' do diff --git a/spec/classes/cloud_orchestration_api_spec.rb b/spec/classes/cloud_orchestration_api_spec.rb index e4cc23fe..12c8ae15 100644 --- a/spec/classes/cloud_orchestration_api_spec.rb +++ b/spec/classes/cloud_orchestration_api_spec.rb @@ -80,6 +80,13 @@ describe 'cloud::orchestration::api' do ) end + it 'checks if Heat DB is populated' do + should contain_exec('heat_db_sync').with( + :command => '/usr/bin/heat-manage --config-file /etc/heat/heat.conf db_sync', + :unless => '/usr/bin/mysql heat -h 10.0.0.1 -u heat -psecrete -e "show tables" | /bin/grep Tables' + ) + end + end context 'on Debian platforms' do diff --git a/spec/classes/cloud_volume_controller_spec.rb b/spec/classes/cloud_volume_controller_spec.rb index c3b7d748..bb96106e 100644 --- a/spec/classes/cloud_volume_controller_spec.rb +++ b/spec/classes/cloud_volume_controller_spec.rb @@ -60,6 +60,13 @@ describe 'cloud::volume::controller' do should contain_class('cinder::ceilometer') end + it 'checks if Cinder DB is populated' do + should contain_exec('cinder_db_sync').with( + :command => '/usr/bin/cinder-manage db sync', + :unless => '/usr/bin/mysql cinder -h 10.0.0.1 -u cinder -psecrete -e "show tables" | /bin/grep Tables' + ) + end + it 'configure cinder scheduler' do should contain_class('cinder::scheduler') end diff --git a/spec/classes/cloud_volume_storage_spec.rb b/spec/classes/cloud_volume_storage_spec.rb index dc5bde48..d86ab186 100644 --- a/spec/classes/cloud_volume_storage_spec.rb +++ b/spec/classes/cloud_volume_storage_spec.rb @@ -58,6 +58,13 @@ describe 'cloud::volume::storage' do end + it 'checks if Cinder DB is populated' do + should contain_exec('cinder_db_sync').with( + :command => '/usr/bin/cinder-manage db sync', + :unless => '/usr/bin/mysql cinder -h 10.0.0.1 -u cinder -psecrete -e "show tables" | /bin/grep Tables' + ) + end + it 'configure cinder volume with rbd backend' do should include_class('cinder::volume')