Skip to content

(MODULES-1685) permit use of mysql::db without mysql::server #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ replicate-do-db = base2
To add custom MySQL configuration, drop additional files into
`/etc/mysql/conf.d/`. Dropping files into conf.d allows you to override settings or add additional ones, which is helpful if you choose not to use `override_options` in `mysql::server`. The conf.d location is hardcoded into the my.cnf template file.

###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

###Classes
Expand Down
8 changes: 5 additions & 3 deletions manifests/db.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
charset => $charset,
collate => $collate,
provider => 'mysql',
require => [ Class['mysql::server'], Class['mysql::client'] ],
require => [ Class['mysql::client'] ],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see here


require  => defined(Class['mysql::server'])? {
                   true  => [ Class['mysql::server'], Class['mysql::client'] ],
                   false => [ Class['mysql::client'] ]
                },

}
ensure_resource('mysql_database', $dbname, $db_resource)

$user_resource = {
ensure => $ensure,
password_hash => mysql_password($password),
provider => 'mysql',
require => Class['mysql::server'],
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add here
Mysql_database[$dbname] -> Mysql_user["${user}@${host}"]
or
require => Mysql_database[$dbname]
this define is called only with all parameters anyway

ensure_resource('mysql_user', "${user}@${host}", $user_resource)

Expand All @@ -41,7 +40,10 @@
provider => 'mysql',
user => "${user}@${host}",
table => $table,
require => [Mysql_database[$dbname], Mysql_user["${user}@${host}"], Class['mysql::server'] ],
require => [
Mysql_database[$dbname],
Mysql_user["${user}@${host}"],
],
}

$refresh = ! $enforce_sql
Expand Down
5 changes: 4 additions & 1 deletion manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,8 @@
Anchor['mysql::server::end']
}


Class['mysql::server'] -> Mysql_database <||>
Class['mysql::server'] -> Mysql_user <||>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of collectors, could you add autorequires for Class['mysql::server'] to the mysql_database and mysql_user types? Adding collectors without filters could do something bad for anyone using virtual resources, like creating all databases on all mysql servers.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hunner It is not possible here due to the aim of patch: we want to use this define without defined class mysql::server(for remote server where mysql server is already installed)
I would offer to clean it up or at least leave as is

}