Add mysql_host param to refstack class

This will allow the mysql host to be passed in, and allow for
a non-localhost mysql server to be used. If mysql_host is passed in
and not 'localhost', then we assume that the mysql_database has
already been created with mysql_user already granted access.

Change-Id: I161d8dd2e605425f8dc9e3e42adf3734cb43e627
This commit is contained in:
Paul Van Eck 2015-10-05 13:36:08 -07:00
parent 4f06b81398
commit 70b1bfc9b5
2 changed files with 13 additions and 8 deletions

View File

@ -18,6 +18,7 @@
# directly from its git repositories. # directly from its git repositories.
# #
class refstack ( class refstack (
$mysql_host = 'localhost',
$mysql_database = 'refstack', $mysql_database = 'refstack',
$mysql_user = 'refstack', $mysql_user = 'refstack',
$mysql_user_password, $mysql_user_password,
@ -35,6 +36,7 @@ class refstack (
# Configure the entire refstack instance. This does not install anything, # Configure the entire refstack instance. This does not install anything,
# but ensures that variables are consistent across all modules. # but ensures that variables are consistent across all modules.
class { '::refstack::params': class { '::refstack::params':
mysql_host => $mysql_host,
mysql_database => $mysql_database, mysql_database => $mysql_database,
mysql_user => $mysql_user, mysql_user => $mysql_user,
mysql_user_password => $mysql_user_password, mysql_user_password => $mysql_user_password,

View File

@ -15,25 +15,28 @@
# == Class: refstack::mysql # == Class: refstack::mysql
# #
# The RefStack MySQL manifest will install a standalone, localhost instance # The RefStack MySQL manifest will install a standalone, localhost instance
# of mysql for refstack to connect to. # of mysql if mysql_host is set to 'localhost'.
# #
class refstack::mysql () { class refstack::mysql () {
require ::refstack::params require ::refstack::params
# Import parameters. # Import parameters.
$mysql_host = $refstack::params::mysql_host
$mysql_database = $refstack::params::mysql_database $mysql_database = $refstack::params::mysql_database
$mysql_user = $refstack::params::mysql_user $mysql_user = $refstack::params::mysql_user
$mysql_user_password = $refstack::params::mysql_user_password $mysql_user_password = $refstack::params::mysql_user_password
# Install MySQL # Install MySQL
include ::mysql::server if $mysql_host == 'localhost' {
include ::mysql::server
# Add the refstack database. # Add the refstack database.
mysql::db { $mysql_database: mysql::db { $mysql_database:
user => $mysql_user, user => $mysql_user,
password => $mysql_user_password, password => $mysql_user_password,
host => 'localhost', host => $mysql_host,
grant => ['all'], grant => ['all'],
}
} }
} }