mirror of
https://github.com/fspc/bike-database.git
synced 2026-09-17 00:51:39 -04:00
move rails app into src/, add Vagrantfile & puppet/ assets and add src/.gitignore file
This commit is contained in:
Executable
+68
@@ -0,0 +1,68 @@
|
||||
# Class: mysql::backup
|
||||
#
|
||||
# This module handles ...
|
||||
#
|
||||
# Parameters:
|
||||
# [*backupuser*] - The name of the mysql backup user.
|
||||
# [*backuppassword*] - The password of the mysql backup user.
|
||||
# [*backupdir*] - The target directory of the mysqldump.
|
||||
#
|
||||
# Actions:
|
||||
# GRANT SELECT, RELOAD, LOCK TABLES ON *.* TO 'user'@'localhost'
|
||||
# IDENTIFIED BY 'password';
|
||||
#
|
||||
# Requires:
|
||||
# Class['mysql::config']
|
||||
#
|
||||
# Sample Usage:
|
||||
# class { 'mysql::backup':
|
||||
# backupuser => 'myuser',
|
||||
# backuppassword => 'mypassword',
|
||||
# backupdir => '/tmp/backups',
|
||||
# }
|
||||
#
|
||||
class mysql::backup (
|
||||
$backupuser,
|
||||
$backuppassword,
|
||||
$backupdir,
|
||||
$ensure = 'present'
|
||||
) {
|
||||
|
||||
database_user { "${backupuser}@localhost":
|
||||
ensure => $ensure,
|
||||
password_hash => mysql_password($backuppassword),
|
||||
provider => 'mysql',
|
||||
require => Class['mysql::config'],
|
||||
}
|
||||
|
||||
database_grant { "${backupuser}@localhost":
|
||||
privileges => [ 'Select_priv', 'Reload_priv', 'Lock_tables_priv' ],
|
||||
require => Database_user["${backupuser}@localhost"],
|
||||
}
|
||||
|
||||
cron { 'mysql-backup':
|
||||
ensure => $ensure,
|
||||
command => '/usr/local/sbin/mysqlbackup.sh',
|
||||
user => 'root',
|
||||
hour => 23,
|
||||
minute => 5,
|
||||
require => File['mysqlbackup.sh'],
|
||||
}
|
||||
|
||||
file { 'mysqlbackup.sh':
|
||||
ensure => $ensure,
|
||||
path => '/usr/local/sbin/mysqlbackup.sh',
|
||||
mode => '0700',
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
content => template('mysql/mysqlbackup.sh.erb'),
|
||||
}
|
||||
|
||||
file { 'mysqlbackupdir':
|
||||
ensure => 'directory',
|
||||
path => $backupdir,
|
||||
mode => '0700',
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
}
|
||||
}
|
||||
Executable
+122
@@ -0,0 +1,122 @@
|
||||
# Class: mysql::config
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# [*root_password*] - root user password.
|
||||
# [*old_root_password*] - previous root user password,
|
||||
# [*bind_address*] - address to bind service.
|
||||
# [*port*] - port to bind service.
|
||||
# [*etc_root_password*] - whether to save /etc/.my.cnf.
|
||||
# [*service_name*] - mysql service name.
|
||||
# [*config_file*] - my.cnf configuration file path.
|
||||
# [*socket*] - mysql socket.
|
||||
# [*datadir*] - path to datadir.
|
||||
# [*ssl] - enable ssl
|
||||
# [*ssl_ca] - path to ssl-ca
|
||||
# [*ssl_cert] - path to ssl-cert
|
||||
# [*ssl_key] - path to ssl-key
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# class mysql::server
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# class { 'mysql::config':
|
||||
# root_password => 'changeme',
|
||||
# bind_address => $::ipaddress,
|
||||
# }
|
||||
#
|
||||
class mysql::config(
|
||||
$root_password = 'UNSET',
|
||||
$old_root_password = '',
|
||||
$bind_address = $mysql::params::bind_address,
|
||||
$port = $mysql::params::port,
|
||||
$etc_root_password = $mysql::params::etc_root_password,
|
||||
$service_name = $mysql::params::service_name,
|
||||
$config_file = $mysql::params::config_file,
|
||||
$socket = $mysql::params::socket,
|
||||
$datadir = $mysql::params::datadir,
|
||||
$ssl = $mysql::params::ssl,
|
||||
$ssl_ca = $mysql::params::ssl_ca,
|
||||
$ssl_cert = $mysql::params::ssl_cert,
|
||||
$ssl_key = $mysql::params::ssl_key,
|
||||
$log_error = $mysql::params::log_error,
|
||||
$default_engine = 'UNSET',
|
||||
$root_group = $mysql::params::root_group
|
||||
) inherits mysql::params {
|
||||
|
||||
File {
|
||||
owner => 'root',
|
||||
group => $root_group,
|
||||
mode => '0400',
|
||||
notify => Exec['mysqld-restart'],
|
||||
}
|
||||
|
||||
if $ssl and $ssl_ca == undef {
|
||||
fail('The ssl_ca parameter is required when ssl is true')
|
||||
}
|
||||
|
||||
if $ssl and $ssl_cert == undef {
|
||||
fail('The ssl_cert parameter is required when ssl is true')
|
||||
}
|
||||
|
||||
if $ssl and $ssl_key == undef {
|
||||
fail('The ssl_key parameter is required when ssl is true')
|
||||
}
|
||||
|
||||
# This kind of sucks, that I have to specify a difference resource for
|
||||
# restart. the reason is that I need the service to be started before mods
|
||||
# to the config file which can cause a refresh
|
||||
exec { 'mysqld-restart':
|
||||
command => "service ${service_name} restart",
|
||||
logoutput => on_failure,
|
||||
refreshonly => true,
|
||||
path => '/sbin/:/usr/sbin/:/usr/bin/:/bin/',
|
||||
}
|
||||
|
||||
# manage root password if it is set
|
||||
if $root_password != 'UNSET' {
|
||||
case $old_root_password {
|
||||
'': { $old_pw='' }
|
||||
default: { $old_pw="-p'${old_root_password}'" }
|
||||
}
|
||||
|
||||
exec { 'set_mysql_rootpw':
|
||||
command => "mysqladmin -u root ${old_pw} password '${root_password}'",
|
||||
logoutput => true,
|
||||
unless => "mysqladmin -u root -p'${root_password}' status > /dev/null",
|
||||
path => '/usr/local/sbin:/usr/bin:/usr/local/bin',
|
||||
notify => Exec['mysqld-restart'],
|
||||
require => File['/etc/mysql/conf.d'],
|
||||
}
|
||||
|
||||
file { '/root/.my.cnf':
|
||||
content => template('mysql/my.cnf.pass.erb'),
|
||||
require => Exec['set_mysql_rootpw'],
|
||||
}
|
||||
|
||||
if $etc_root_password {
|
||||
file{ '/etc/my.cnf':
|
||||
content => template('mysql/my.cnf.pass.erb'),
|
||||
require => Exec['set_mysql_rootpw'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file { '/etc/mysql':
|
||||
ensure => directory,
|
||||
mode => '0755',
|
||||
}
|
||||
file { '/etc/mysql/conf.d':
|
||||
ensure => directory,
|
||||
mode => '0755',
|
||||
}
|
||||
file { $config_file:
|
||||
content => template('mysql/my.cnf.erb'),
|
||||
mode => '0644',
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
# Define: mysql::db
|
||||
#
|
||||
# This module creates database instances, a user, and grants that user
|
||||
# privileges to the database. It can also import SQL from a file in order to,
|
||||
# for example, initialize a database schema.
|
||||
#
|
||||
# Since it requires class mysql::server, we assume to run all commands as the
|
||||
# root mysql user against the local mysql server.
|
||||
#
|
||||
# Parameters:
|
||||
# [*title*] - mysql database name.
|
||||
# [*user*] - username to create and grant access.
|
||||
# [*password*] - user's password.
|
||||
# [*charset*] - database charset.
|
||||
# [*host*] - host for assigning privileges to user.
|
||||
# [*grant*] - array of privileges to grant user.
|
||||
# [*enforce_sql*] - whether to enforce or conditionally run sql on creation.
|
||||
# [*sql*] - sql statement to run.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# class mysql::server
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
# mysql::db { 'mydb':
|
||||
# user => 'my_user',
|
||||
# password => 'password',
|
||||
# host => $::hostname,
|
||||
# grant => ['all']
|
||||
# }
|
||||
#
|
||||
define mysql::db (
|
||||
$user,
|
||||
$password,
|
||||
$charset = 'utf8',
|
||||
$host = 'localhost',
|
||||
$grant = 'all',
|
||||
$sql = '',
|
||||
$enforce_sql = false
|
||||
) {
|
||||
|
||||
database { $name:
|
||||
ensure => present,
|
||||
charset => $charset,
|
||||
provider => 'mysql',
|
||||
require => Class['mysql::server'],
|
||||
}
|
||||
|
||||
database_user { "${user}@${host}":
|
||||
ensure => present,
|
||||
password_hash => mysql_password($password),
|
||||
provider => 'mysql',
|
||||
require => Database[$name],
|
||||
}
|
||||
|
||||
database_grant { "${user}@${host}/${name}":
|
||||
privileges => $grant,
|
||||
provider => 'mysql',
|
||||
require => Database_user["${user}@${host}"],
|
||||
}
|
||||
|
||||
$refresh = ! $enforce_sql
|
||||
|
||||
if $sql {
|
||||
exec{ "${name}-import":
|
||||
command => "/usr/bin/mysql ${name} < ${sql}",
|
||||
logoutput => true,
|
||||
refreshonly => $refresh,
|
||||
require => Database_grant["${user}@${host}/${name}"],
|
||||
subscribe => Database[$name],
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
# Class: mysql
|
||||
#
|
||||
# This class installs mysql client software.
|
||||
#
|
||||
# Parameters:
|
||||
# [*client_package_name*] - The name of the mysql client package.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
class mysql (
|
||||
$package_name = $mysql::params::client_package_name,
|
||||
$package_ensure = 'present'
|
||||
) inherits mysql::params {
|
||||
|
||||
package { 'mysql_client':
|
||||
name => $package_name,
|
||||
ensure => $package_ensure,
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
# Class: mysql::java
|
||||
#
|
||||
# This class installs the mysql-java-connector.
|
||||
#
|
||||
# Parameters:
|
||||
# [*java_package_name*] - The name of the mysql java package.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
class mysql::java (
|
||||
$package_name = $mysql::params::java_package_name,
|
||||
$package_ensure = 'present'
|
||||
) inherits mysql::params {
|
||||
|
||||
package { 'mysql-connector-java':
|
||||
ensure => $package_ensure,
|
||||
name => $package_name,
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
# Class: mysql::params
|
||||
#
|
||||
# The mysql configuration settings.
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
class mysql::params {
|
||||
|
||||
$bind_address = '127.0.0.1'
|
||||
$port = 3306
|
||||
$etc_root_password = false
|
||||
$ssl = false
|
||||
|
||||
case $::operatingsystem {
|
||||
"Ubuntu": {
|
||||
$service_provider = upstart
|
||||
}
|
||||
default: {
|
||||
$service_provider = undef
|
||||
}
|
||||
}
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$basedir = '/usr'
|
||||
$datadir = '/var/lib/mysql'
|
||||
$service_name = 'mysqld'
|
||||
$client_package_name = 'mysql'
|
||||
$server_package_name = 'mysql-server'
|
||||
$socket = '/var/lib/mysql/mysql.sock'
|
||||
$config_file = '/etc/my.cnf'
|
||||
$log_error = '/var/log/mysqld.log'
|
||||
$ruby_package_name = 'ruby-mysql'
|
||||
$ruby_package_provider = 'gem'
|
||||
$python_package_name = 'MySQL-python'
|
||||
$java_package_name = 'mysql-connector-java'
|
||||
$root_group = 'root'
|
||||
$ssl_ca = '/etc/mysql/cacert.pem'
|
||||
$ssl_cert = '/etc/mysql/server-cert.pem'
|
||||
$ssl_key = '/etc/mysql/server-key.pem'
|
||||
}
|
||||
|
||||
'Debian': {
|
||||
$basedir = '/usr'
|
||||
$datadir = '/var/lib/mysql'
|
||||
$service_name = 'mysql'
|
||||
$client_package_name = 'mysql-client'
|
||||
$server_package_name = 'mysql-server'
|
||||
$socket = '/var/run/mysqld/mysqld.sock'
|
||||
$config_file = '/etc/mysql/my.cnf'
|
||||
$log_error = '/var/log/mysql/error.log'
|
||||
$ruby_package_name = 'libmysql-ruby'
|
||||
$python_package_name = 'python-mysqldb'
|
||||
$java_package_name = 'libmysql-java'
|
||||
$root_group = 'root'
|
||||
$ssl_ca = '/etc/mysql/cacert.pem'
|
||||
$ssl_cert = '/etc/mysql/server-cert.pem'
|
||||
$ssl_key = '/etc/mysql/server-key.pem'
|
||||
}
|
||||
|
||||
'FreeBSD': {
|
||||
$basedir = '/usr/local'
|
||||
$datadir = '/var/db/mysql'
|
||||
$service_name = 'mysql-server'
|
||||
$client_package_name = 'databases/mysql55-client'
|
||||
$server_package_name = 'databases/mysql55-server'
|
||||
$socket = '/tmp/mysql.sock'
|
||||
$config_file = '/var/db/mysql/my.cnf'
|
||||
$log_error = "/var/db/mysql/${::hostname}.err"
|
||||
$ruby_package_name = 'ruby-mysql'
|
||||
$ruby_package_provider = 'gem'
|
||||
$python_package_name = 'databases/py-MySQLdb'
|
||||
$java_package_name = 'databases/mysql-connector-java'
|
||||
$root_group = 'wheel'
|
||||
$ssl_ca = undef
|
||||
$ssl_cert = undef
|
||||
$ssl_key = undef
|
||||
}
|
||||
|
||||
default: {
|
||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat Debian and FreeBSD")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
# Class: mysql::python
|
||||
#
|
||||
# This class installs the python libs for mysql.
|
||||
#
|
||||
# Parameters:
|
||||
# [*ensure*] - ensure state for package.
|
||||
# can be specified as version.
|
||||
# [*package_name*] - name of package
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
class mysql::python(
|
||||
$package_name = $mysql::params::python_package_name,
|
||||
$package_ensure = 'present'
|
||||
) inherits mysql::params {
|
||||
|
||||
package { 'python-mysqldb':
|
||||
name => $package_name,
|
||||
ensure => $package_ensure,
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
# Class: mysql::ruby
|
||||
#
|
||||
# installs the ruby bindings for mysql
|
||||
#
|
||||
# Parameters:
|
||||
# [*ensure*] - ensure state for package.
|
||||
# can be specified as version.
|
||||
# [*package_name*] - name of package
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
class mysql::ruby (
|
||||
$package_name = $mysql::params::ruby_package_name,
|
||||
$package_provider = $mysql::params::ruby_package_provider,
|
||||
$package_ensure = 'present'
|
||||
) inherits mysql::params {
|
||||
|
||||
package{ 'ruby_mysql':
|
||||
name => $package_name,
|
||||
ensure => $package_ensure,
|
||||
provider => $package_provider,
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
# Class: mysql::server
|
||||
#
|
||||
# manages the installation of the mysql server. manages the package, service,
|
||||
# my.cnf
|
||||
#
|
||||
# Parameters:
|
||||
# [*package_name*] - name of package
|
||||
# [*service_name*] - name of service
|
||||
# [*config_hash*] - hash of config parameters that need to be set.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
class mysql::server (
|
||||
$package_name = $mysql::params::server_package_name,
|
||||
$package_ensure = 'present',
|
||||
$service_name = $mysql::params::service_name,
|
||||
$service_provider = $mysql::params::service_provider,
|
||||
$config_hash = {},
|
||||
$enabled = true
|
||||
) inherits mysql::params {
|
||||
|
||||
Class['mysql::server'] -> Class['mysql::config']
|
||||
|
||||
$config_class = {}
|
||||
$config_class['mysql::config'] = $config_hash
|
||||
|
||||
create_resources( 'class', $config_class )
|
||||
|
||||
package { 'mysql-server':
|
||||
name => $package_name,
|
||||
ensure => $package_ensure,
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
service { 'mysqld':
|
||||
name => $service_name,
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
require => Package['mysql-server'],
|
||||
provider => $service_provider,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class mysql::server::account_security {
|
||||
# Some installations have some default users which are not required.
|
||||
# We remove them here. You can subclass this class to overwrite this behavior.
|
||||
database_user { [ "root@${::fqdn}", "root@${::hostname}", 'root@127.0.0.1',
|
||||
"@${::fqdn}", "@${::hostname}", '@localhost', '@%' ]:
|
||||
ensure => 'absent',
|
||||
require => Class['mysql::config'],
|
||||
}
|
||||
database { 'test':
|
||||
ensure => 'absent',
|
||||
require => Class['mysql::config'],
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
class mysql::server::monitor (
|
||||
$mysql_monitor_username,
|
||||
$mysql_monitor_password,
|
||||
$mysql_monitor_hostname
|
||||
) {
|
||||
|
||||
Class['mysql::server'] -> Class['mysql::server::monitor']
|
||||
|
||||
database_user{ "${mysql_monitor_username}@${mysql_monitor_hostname}":
|
||||
password_hash => mysql_password($mysql_monitor_password),
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
database_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}":
|
||||
privileges => [ 'process_priv', 'super_priv' ],
|
||||
require => Mysql_user["${mysql_monitor_username}@${mysql_monitor_hostname}"],
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
# Copyright 2009 Larry Ludwig (larrylud@gmail.com)
|
||||
#
|
||||
# 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 mysql::server::mysqltuner {
|
||||
# mysql performance tester
|
||||
file { '/usr/bin/mysqltuner':
|
||||
ensure => present,
|
||||
mode => '0550',
|
||||
source => 'puppet:///modules/mysql/mysqltuner.pl',
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user