Move db syncs into mysql base role
authorDan Prince <dprince@redhat.com>
Mon, 26 Sep 2016 16:48:49 +0000 (12:48 -0400)
committerDan Prince <dprince@redhat.com>
Tue, 27 Sep 2016 16:08:20 +0000 (12:08 -0400)
This patch moves the various DB syncs into the MySQL role.

Database creation needs to occur on the MySQL server to
avoid permission issues.

This patch also moves database creation to step 2 so we can
guarantee that all per-service databases exist at this time.
This avoids complex ordering needed during step 3 where
services, on different hosts, can run their own db sync's
in a distributed fashion.

Change-Id: I05cc0afa9373429a3197c194c3e8f784ae96de5f
Partial-bug: #1620595

16 files changed:
manifests/profile/base/aodh.pp
manifests/profile/base/ceilometer/collector.pp
manifests/profile/base/cinder/api.pp
manifests/profile/base/database/mysql.pp
manifests/profile/base/glance/registry.pp
manifests/profile/base/gnocchi/api.pp
manifests/profile/base/heat/engine.pp
manifests/profile/base/ironic.pp
manifests/profile/base/keystone.pp
manifests/profile/base/manila/api.pp
manifests/profile/base/mistral.pp
manifests/profile/base/neutron/server.pp
manifests/profile/base/nova/api.pp
manifests/profile/base/sahara/engine.pp
manifests/profile/base/trove/api.pp
manifests/profile/pacemaker/database/mysql.pp

index 2fad5b3..49a543a 100644 (file)
@@ -44,10 +44,6 @@ class tripleo::profile::base::aodh (
     $sync_db = false
   }
 
-  if $step >= 3 and $sync_db {
-    include ::aodh::db::mysql
-  }
-
   if $step >= 4 or ($step >= 3 and $sync_db) {
     class { '::aodh' :
       rabbit_hosts => $rabbit_hosts,
index baaf4c8..e892478 100644 (file)
@@ -59,10 +59,6 @@ class tripleo::profile::base::ceilometer::collector (
 
   include ::tripleo::profile::base::ceilometer
 
-  if $step >= 2 and $sync_db and $ceilometer_backend == 'mysql' {
-    include ::ceilometer::db::mysql
-  }
-
   if $step >= 3 and $sync_db {
     include ::ceilometer::db::sync
   }
index 370b402..31635eb 100644 (file)
@@ -39,10 +39,6 @@ class tripleo::profile::base::cinder::api (
 
   include ::tripleo::profile::base::cinder
 
-  if $step >= 3 and $sync_db {
-    include ::cinder::db::mysql
-  }
-
   if $step >= 4 or ($step >= 3 and $sync_db) {
     include ::cinder::api
     include ::cinder::ceilometer
index 31a90ec..9da1456 100644 (file)
 #   (Optional) The address that the local mysql instance should bind to.
 #   Defaults to $::hostname
 #
+# [*bootstrap_node*]
+#   (Optional) The hostname of the node responsible for bootstrapping tasks
+#   Defaults to hiera('bootstrap_nodeid')
+#
 # [*manage_resources*]
 #   (Optional) Whether or not manage root user, root my.cnf, and service.
 #   Defaults to true
 #
 class tripleo::profile::base::database::mysql (
   $bind_address            = $::hostname,
+  $bootstrap_node          = hiera('bootstrap_nodeid', undef),
   $manage_resources        = true,
   $mysql_server_options    = {},
   $remove_default_accounts = true,
   $step                    = hiera('step'),
 ) {
 
+  if $::hostname == downcase($bootstrap_node) {
+    $sync_db = true
+  } else {
+    $sync_db = false
+  }
+
   validate_hash($mysql_server_options)
 
   # non-ha scenario
@@ -87,4 +98,51 @@ class tripleo::profile::base::database::mysql (
     }
   }
 
+  if $step >= 2 and $sync_db {
+    Class['::mysql::server'] -> Mysql_database<||>
+    if hiera('aodh_api_enabled', false) {
+      include ::aodh::db::mysql
+    }
+    if hiera('ceilometer_collector_enabled', false) {
+      include ::ceilometer::db::mysql
+    }
+    if hiera('cinder_api_enabled', false) {
+      include ::cinder::db::mysql
+    }
+    if hiera('glance_registry_enabled', false) {
+      include ::glance::db::mysql
+    }
+    if hiera('gnocchi_api_enabled', false) {
+      include ::gnocchi::db::mysql
+    }
+    if hiera('heat_engine_enabled', false) {
+      include ::heat::db::mysql
+    }
+    if hiera('ironic_api_enabled', false) {
+      include ::ironic::db::mysql
+    }
+    if hiera('keystone_enabled', false) {
+      include ::keystone::db::mysql
+    }
+    if hiera('manila_api_enabled', false) {
+      include ::manila::db::mysql
+    }
+    if hiera('mistral_api_enabled', false) {
+      include ::mistral::db::mysql
+    }
+    if hiera('neutron_api_enabled', false) {
+      include ::neutron::db::mysql
+    }
+    if hiera('nova_api_enabled', false) {
+      include ::nova::db::mysql
+      include ::nova::db::mysql_api
+    }
+    if hiera('sahara_api_enabled', false) {
+      include ::sahara::db::mysql
+    }
+    if hiera('trove_api_enabled', false) {
+      include ::trove::db::mysql
+    }
+  }
+
 }
index ac6796a..9e2be9d 100644 (file)
@@ -42,10 +42,6 @@ class tripleo::profile::base::glance::registry (
     $sync_db = false
   }
 
-  if $step >= 3 and $sync_db {
-    include ::glance::db::mysql
-  }
-
   if $step >= 4 or ( $step >= 3 and $sync_db ) {
     # TODO: notifications, scrubber, etc.
     include ::glance
index 5e7e215..732ea26 100644 (file)
@@ -45,7 +45,6 @@ class tripleo::profile::base::gnocchi::api (
   include ::tripleo::profile::base::gnocchi
 
   if $step >= 3 and $sync_db {
-    include ::gnocchi::db::mysql
     include ::gnocchi::db::sync
   }
 
index 112fad8..479e1c6 100644 (file)
@@ -39,10 +39,6 @@ class tripleo::profile::base::heat::engine (
 
   include ::tripleo::profile::base::heat
 
-  if $step >= 3 and $sync_db {
-    include ::heat::db::mysql
-  }
-
   if $step >= 4 or ( $step >= 3 and $sync_db ) {
     include ::heat::engine
   }
index 6c0769a..c4e525a 100644 (file)
@@ -42,10 +42,6 @@ class tripleo::profile::base::ironic (
     $sync_db = false
   }
 
-  if $step >= 3 and $sync_db {
-    include ::ironic::db::mysql
-  }
-
   if $step >= 4 or ($step >= 3 and $sync_db) {
     class { '::ironic':
       sync_db      => $sync_db,
index fd38869..d515f8f 100644 (file)
@@ -51,10 +51,6 @@ class tripleo::profile::base::keystone (
     $manage_endpoint = false
   }
 
-  if $step >= 3 and $sync_db {
-    include ::keystone::db::mysql
-  }
-
   if $step >= 4 or ( $step >= 3 and $sync_db ) {
     class { '::keystone':
       sync_db          => $sync_db,
index ca5455f..1f78ab3 100644 (file)
@@ -39,10 +39,6 @@ class tripleo::profile::base::manila::api (
 
   include ::tripleo::profile::base::manila
 
-  if $step >= 3 and $sync_db {
-    include ::manila::db::mysql
-  }
-
   if $step >= 4 or ($step >= 3 and $sync_db) {
     include ::manila::api
   }
index 3ebc3d5..9986d22 100644 (file)
@@ -42,10 +42,6 @@ class tripleo::profile::base::mistral (
     $sync_db = false
   }
 
-  if $step >= 3 and $sync_db {
-    include ::mistral::db::mysql
-  }
-
   if $step >= 4 or ($step >= 3 and $sync_db) {
     class  { '::mistral':
       rabbit_hosts => $rabbit_hosts,
index 5a1b377..82c2d5f 100644 (file)
@@ -39,10 +39,6 @@ class tripleo::profile::base::neutron::server (
 
   include ::tripleo::profile::base::neutron
 
-  if $step >= 3 and $sync_db {
-    include ::neutron::db::mysql
-  }
-
   # We start neutron-server on the bootstrap node first, because
   # it will try to populate tables and we need to make sure this happens
   # before it starts on other nodes
index 285e0b7..3c472c5 100644 (file)
@@ -37,11 +37,6 @@ class tripleo::profile::base::nova::api (
 
   include ::tripleo::profile::base::nova
 
-  if $step >= 3 and $sync_db {
-    include ::nova::db::mysql
-    include ::nova::db::mysql_api
-  }
-
   if $step >= 4 or ($step >= 3 and $sync_db) {
     class { '::nova::api':
       sync_db     => $sync_db,
index 4dbaa85..e2da0e7 100644 (file)
@@ -39,10 +39,6 @@ class tripleo::profile::base::sahara::engine (
 
   include ::tripleo::profile::base::sahara
 
-  if $step >= 3 and $sync_db {
-    include ::sahara::db::mysql
-  }
-
   if $step >= 4 or ($step >= 3 and $sync_db) {
     include ::sahara::service::engine
   }
index 7a78171..bc16e6e 100644 (file)
@@ -37,10 +37,6 @@ class tripleo::profile::base::trove::api (
     $sync_db = false
   }
 
-  if $step >= 3 and $sync_db {
-    include ::trove::db::mysql
-  }
-
   if $step >= 4 or ($step >= 3 and $sync_db) {
     include ::trove
     include ::trove::config
index c688240..57568ab 100644 (file)
@@ -125,6 +125,11 @@ class tripleo::profile::pacemaker::database::mysql (
         table      => '*.*',
         user       => 'clustercheck@localhost',
       }
+
+      # We create databases for services at step 2 as well. This ensures
+      # Galara is up before those get created
+      Exec['galera-ready'] -> Mysql_database<||>
+
     }
     # This step is to create a sysconfig clustercheck file with the root user and empty password
     # on the first install only (because later on the clustercheck db user will be used)