diff --git a/Modulefile b/Modulefile index 18a6985..daf53da 100644 --- a/Modulefile +++ b/Modulefile @@ -10,3 +10,4 @@ project_page 'https://github.com/openstack-ci/puppet-refstack' ## Add dependencies, if any: dependency 'stankevich/python', '= 1.6.6' dependency 'openstackci/vcsrepo', '= 0.0.8' +dependency 'puppetlabs/mysql', '= 0.6.1' diff --git a/manifests/init.pp b/manifests/init.pp index 79f7128..0c5bf0f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -17,12 +17,20 @@ # This class installs and updates refstack in a continuous-deployment fashion # directly from its git repositories. # -class refstack () { +class refstack ( + $mysql_database = 'refstack', + $mysql_user = 'refstack', + $mysql_user_password, +) { # Configure the entire refstack instance. This does not install anything, # but ensures that variables are consistent across all modules. class { '::refstack::params': + mysql_database => $mysql_database, + mysql_user => $mysql_user, + mysql_user_password => $mysql_user_password, } + include ::refstack::mysql include ::refstack::api } diff --git a/manifests/mysql.pp b/manifests/mysql.pp new file mode 100644 index 0000000..db141ec --- /dev/null +++ b/manifests/mysql.pp @@ -0,0 +1,39 @@ +# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# == Class: refstack::mysql +# +# The Refstack MySQL manifest will install a standalone, localhost instance +# of mysql for refstack to connect to. +# +class refstack::mysql () { + + require ::refstack::params + + # Import parameters. + $mysql_database = $refstack::params::mysql_database + $mysql_user = $refstack::params::mysql_user + $mysql_user_password = $refstack::params::mysql_user_password + + # Install MySQL + include mysql::server + + # Add the storyboard database. + mysql::db { $mysql_database: + user => $mysql_user, + password => $mysql_user_password, + host => 'localhost', + grant => ['all'], + } +} \ No newline at end of file diff --git a/manifests/params.pp b/manifests/params.pp index 134c8d5..cde00c4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -25,6 +25,13 @@ class refstack::params ( # The user under which refstack will run. $user = 'refstack', $group = 'refstack', + + # [database] refstack.conf + $mysql_user = 'refstack', + $mysql_user_password, + $mysql_host = localhost, + $mysql_port = 3306, + $mysql_database = 'refstack', ) { # Resolve a few parameters based on the install environment. @@ -34,4 +41,8 @@ class refstack::params ( # Create our install directory with a python-versioned name (because venv). $install_api_root = "/var/lib/refstack-py${python_version}" + + # Build the connection string from individual parameters + $mysql_connection_string = "mysql://${mysql_user}:${mysql_user_password}@${mysql_host}:${mysql_port}/${mysql_database}" + } diff --git a/metadata.json b/metadata.json index 7289083..bd779a7 100644 --- a/metadata.json +++ b/metadata.json @@ -15,6 +15,10 @@ { "name": "openstackci/vcsrepo", "version_requirement": ">= 0.0.8" + }, + { + "name": "puppetlabs/mysql", + "version_requirement": ">= 0.6.1" } ] } diff --git a/vagrant.pp b/vagrant.pp index 95b862a..90e1f83 100644 --- a/vagrant.pp +++ b/vagrant.pp @@ -1,4 +1,5 @@ node default { class { 'refstack': + mysql_user_password => 'refstack', } } \ No newline at end of file diff --git a/vagrant.sh b/vagrant.sh index 6b66c71..5792deb 100644 --- a/vagrant.sh +++ b/vagrant.sh @@ -20,4 +20,7 @@ if [ ! -d /etc/puppet/modules/python ]; then fi if [ ! -d /etc/puppet/modules/vcsrepo ]; then puppet module install openstackci-vcsrepo --version 0.0.8 +fi +if [ ! -d /etc/puppet/modules/mysql ]; then + puppet module install puppetlabs-mysql --version 0.6.1 fi \ No newline at end of file