[#puppethack] use of mysql::db without mysql::server
This removes the hard dependencies on mysql::server from manifests/db.pp. This permits one to use this module to manage databases in an existing server, possibly located on a remote host (with a properly configured /root/.my.cnf).
This commit is contained in:
parent
fd03318331
commit
23a4a362a0
2 changed files with 20 additions and 3 deletions
15
README.md
15
README.md
|
@ -146,6 +146,21 @@ mysql::db { 'mydb':
|
||||||
To add custom MySQL configuration, drop additional files into
|
To add custom MySQL configuration, drop additional files into
|
||||||
`includedir`. Dropping files into `includedir` allows you to override settings or add additional ones, which is helpful if you choose not to use `override_options` in `mysql::server`. The `includedir` location is by default set to /etc/mysql/conf.d.
|
`includedir`. Dropping files into `includedir` allows you to override settings or add additional ones, which is helpful if you choose not to use `override_options` in `mysql::server`. The `includedir` location is by default set to /etc/mysql/conf.d.
|
||||||
|
|
||||||
|
###Working with an existing server
|
||||||
|
|
||||||
|
It is possible to use the MySQL module to instantiate databases and
|
||||||
|
users on an existing MySQL server. For this to work, you will need an
|
||||||
|
appropriate `.my.cnf` in `root`'s home directory containing the remote
|
||||||
|
server address and credentials. For example:
|
||||||
|
|
||||||
|
[client]
|
||||||
|
user=root
|
||||||
|
host=localhost
|
||||||
|
password=secret
|
||||||
|
|
||||||
|
When working with a remote server, you will *not* use the
|
||||||
|
`mysql::server` class in your Puppet manifests.
|
||||||
|
|
||||||
##Reference
|
##Reference
|
||||||
|
|
||||||
###Classes
|
###Classes
|
||||||
|
|
|
@ -34,7 +34,7 @@ define mysql::db (
|
||||||
charset => $charset,
|
charset => $charset,
|
||||||
collate => $collate,
|
collate => $collate,
|
||||||
provider => 'mysql',
|
provider => 'mysql',
|
||||||
require => [ Class['mysql::server'], Class['mysql::client'] ],
|
require => [ Class['mysql::client'] ],
|
||||||
}
|
}
|
||||||
ensure_resource('mysql_database', $dbname, $db_resource)
|
ensure_resource('mysql_database', $dbname, $db_resource)
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ define mysql::db (
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
password_hash => mysql_password($password),
|
password_hash => mysql_password($password),
|
||||||
provider => 'mysql',
|
provider => 'mysql',
|
||||||
require => Class['mysql::server'],
|
|
||||||
}
|
}
|
||||||
ensure_resource('mysql_user', "${user}@${host}", $user_resource)
|
ensure_resource('mysql_user', "${user}@${host}", $user_resource)
|
||||||
|
|
||||||
|
@ -52,7 +51,10 @@ define mysql::db (
|
||||||
provider => 'mysql',
|
provider => 'mysql',
|
||||||
user => "${user}@${host}",
|
user => "${user}@${host}",
|
||||||
table => $table,
|
table => $table,
|
||||||
require => [Mysql_database[$dbname], Mysql_user["${user}@${host}"], Class['mysql::server'] ],
|
require => [
|
||||||
|
Mysql_database[$dbname],
|
||||||
|
Mysql_user["${user}@${host}"],
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
$refresh = ! $enforce_sql
|
$refresh = ! $enforce_sql
|
||||||
|
|
Loading…
Reference in a new issue