From 48ca4a6e1c5a8a219fc5fd8b338ef476652cf5cf Mon Sep 17 00:00:00 2001 From: Dan Schaefer Date: Wed, 14 Aug 2013 12:00:12 -0400 Subject: [PATCH] Adding documentation and dependencies for mysql::grant::mysql_db_init_query_file --- README.md | 3 ++- manifests/grant.pp | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 41e3eea..621a7bb 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ For detailed info about the logic and usage patterns of Example42 modules read R root_password => 'auto', } -* Create a new grant and database +* Create a new grant and database. mysql_db_init_query_file is optional and will run only once. mysql::grant { 'db1': mysql_privileges => 'ALL', @@ -36,6 +36,7 @@ For detailed info about the logic and usage patterns of Example42 modules read R mysql_db => 'db1', mysql_user => 'db1', mysql_host => 'host', + mysql_db_init_query_file => '/full/path/to/the/schema.sql', } diff --git a/manifests/grant.pp b/manifests/grant.pp index 608eabb..28ec49f 100644 --- a/manifests/grant.pp +++ b/manifests/grant.pp @@ -4,20 +4,23 @@ # grant statement and then applies it. # # Supported arguments: -# $mysql_db - The database to apply the grant to. -# If not set, defaults to == $title -# It supports SQL wildcards (%), ie: 'somedatab%'. -# The special value '*' means 'ALL DATABASES' -# $mysql_user - User to grant the permissions to. -# $mysql_password - Plaintext password for the user. -# $mysql_create_db - If you want a $mysql_db database created or not. -# Default: true. -# $mysql_privileges - Privileges to grant to the user. -# Defaults to 'ALL' -# $mysql_host - Host where the user can connect from. Accepts SQL wildcards. -# Default: 'localhost' -# $mysql_grant_filepath - Path where the grant files will be stored. -# Default: '/root/puppet-mysql' +# $mysql_db - The database to apply the grant to. +# If not set, defaults to == $title +# It supports SQL wildcards (%), ie: 'somedatab%'. +# The special value '*' means 'ALL DATABASES' +# $mysql_user - User to grant the permissions to. +# $mysql_password - Plaintext password for the user. +# $mysql_create_db - If you want a $mysql_db database created or not. +# Default: true. +# $mysql_privileges - Privileges to grant to the user. +# Defaults to 'ALL' +# $mysql_host - Host where the user can connect from. Accepts SQL wildcards. +# Default: 'localhost' +# $mysql_grant_filepath - Path where the grant files will be stored. +# Default: '/root/puppet-mysql' +# $mysql_db_init_query_file - Location of a sql file typically used to create the schema. +# $mysql_create_db must be true or the database must exist. +# Default: '' define mysql::grant ( $mysql_user, $mysql_password, @@ -96,13 +99,14 @@ refreshonly => true; } - if $mysql_db_init_query_file != '' { + if $mysql_db_init_query_file != '' and $mysql_create_db == true { mysql::queryfile { "mysql_db_init_query_file-${mysql_host}-${dbname}": mysql_file => $mysql_db_init_query_file, mysql_user => $mysql_user, mysql_password => $mysql_password, mysql_db => $mysql_db, mysql_host => $mysql_host, + subscribe => Exec["mysqlgrant-${mysql_user}-${mysql_host}-${dbname}"], } } }