From 6a2e31da4baa0e7e68c17a60a7594017495572a3 Mon Sep 17 00:00:00 2001 From: Khai Do Date: Wed, 2 Oct 2013 15:17:01 -0700 Subject: [PATCH] decouple mysql setup from gerrit module This commit moves the MySQL configuration from the gerrit puppet module into a seperate mysql puppet module. The purpose of this change is to allow us to more easily customise gerrit's mysql configuration for each instance of gerrit that we deploy.. Partial-Bug: 1083101 Change-Id: Ibcc31b3fce8af54229fd4de69a49842ac1c428ae --- modules/gerrit/manifests/init.pp | 25 --------------- modules/gerrit/manifests/mysql.pp | 32 +++++++++++++++++++ modules/openstack_project/manifests/gerrit.pp | 4 --- modules/openstack_project/manifests/review.pp | 9 ++++++ .../openstack_project/manifests/review_dev.pp | 11 +++++-- 5 files changed, 50 insertions(+), 31 deletions(-) create mode 100644 modules/gerrit/manifests/mysql.pp diff --git a/modules/gerrit/manifests/init.pp b/modules/gerrit/manifests/init.pp index 1d2ed192a1..0013e24df4 100644 --- a/modules/gerrit/manifests/init.pp +++ b/modules/gerrit/manifests/init.pp @@ -67,8 +67,6 @@ # class gerrit( $war = '', - $mysql_password = '', - $mysql_root_password = '', $email_private_key = '', $vhost_name = $::fqdn, $canonicalweburl = "https://${::fqdn}/", @@ -241,29 +239,6 @@ class gerrit( require => File['/home/gerrit2/review_site/etc'], } - # Set up MySQL. - - class { 'mysql::server': - config_hash => { - 'root_password' => $mysql_root_password, - 'default_engine' => 'InnoDB', - 'bind_address' => '127.0.0.1', - } - } - include mysql::server::account_security - - mysql::db { 'reviewdb': - user => 'gerrit2', - password => $mysql_password, - host => 'localhost', - grant => ['all'], - charset => 'latin1', - require => [ - Class['mysql::server'], - Class['mysql::server::account_security'], - ], - } - # Set up apache. apache::vhost { $vhost_name: diff --git a/modules/gerrit/manifests/mysql.pp b/modules/gerrit/manifests/mysql.pp new file mode 100644 index 0000000000..cc834d9b05 --- /dev/null +++ b/modules/gerrit/manifests/mysql.pp @@ -0,0 +1,32 @@ +# == Class: gerrit::mysql +# +class gerrit::mysql( + $mysql_root_password = '', + $database_name = '', + $database_user = '', + $database_password = '', +) { + + class { 'mysql::server': + config_hash => { + 'root_password' => $mysql_root_password, + 'default_engine' => 'InnoDB', + 'bind_address' => '127.0.0.1', + } + } + include mysql::server::account_security + + mysql::db { $database_name: + user => $database_user, + password => $database_password, + host => 'localhost', + grant => ['all'], + charset => 'latin1', + require => [ + Class['mysql::server'], + Class['mysql::server::account_security'], + ], + } +} + +# vim:sw=2:ts=2:expandtab:textwidth=79 diff --git a/modules/openstack_project/manifests/gerrit.pp b/modules/openstack_project/manifests/gerrit.pp index 428ad91328..3f13ba7600 100644 --- a/modules/openstack_project/manifests/gerrit.pp +++ b/modules/openstack_project/manifests/gerrit.pp @@ -45,8 +45,6 @@ class openstack_project::gerrit ( $github_oauth_token = '', $github_project_username = '', $github_project_password = '', - $mysql_password = '', - $mysql_root_password = '', $trivial_rebase_role_id = '', $email_private_key = '', $replicate_local = true, @@ -150,8 +148,6 @@ class openstack_project::gerrit ( contactstore_appsec => $contactstore_appsec, contactstore_pubkey => $contactstore_pubkey, contactstore_url => $contactstore_url, - mysql_password => $mysql_password, - mysql_root_password => $mysql_root_password, email_private_key => $email_private_key, replicate_local => $replicate_local, replication => $replication, diff --git a/modules/openstack_project/manifests/review.pp b/modules/openstack_project/manifests/review.pp index 27d941b260..301cd2b836 100644 --- a/modules/openstack_project/manifests/review.pp +++ b/modules/openstack_project/manifests/review.pp @@ -70,6 +70,15 @@ class openstack_project::review ( $swift_username = '', $swift_password = '' ) { + + # Setup MySQL + class { 'gerrit::mysql': + mysql_root_password => $mysql_root_password, + database_name => 'reviewdb', + database_user => 'gerrit2', + database_password => $mysql_password, + } + class { 'openstack_project::gerrit': ssl_cert_file => '/etc/ssl/certs/review.openstack.org.pem', diff --git a/modules/openstack_project/manifests/review_dev.pp b/modules/openstack_project/manifests/review_dev.pp index 06cfa848bf..993a57aefa 100644 --- a/modules/openstack_project/manifests/review_dev.pp +++ b/modules/openstack_project/manifests/review_dev.pp @@ -24,6 +24,15 @@ class openstack_project::review_dev ( $swift_username = '', $swift_password = '' ) { + + # Setup MySQL + class { 'gerrit::mysql': + mysql_root_password => $mysql_root_password, + database_name => 'reviewdb', + database_user => 'gerrit2', + database_password => $mysql_password, + } + class { 'openstack_project::gerrit': vhost_name => 'review-dev.openstack.org', canonicalweburl => 'https://review-dev.openstack.org/', @@ -53,8 +62,6 @@ class openstack_project::review_dev ( github_oauth_token => $github_oauth_token, github_project_username => $github_project_username, github_project_password => $github_project_password, - mysql_password => $mysql_password, - mysql_root_password => $mysql_root_password, trivial_rebase_role_id => 'trivial-rebase@review-dev.openstack.org', email_private_key => $email_private_key,