From 0e04add6a00fd5dba11a4716785b8c2e99a53859 Mon Sep 17 00:00:00 2001 From: Markus Burger Date: Tue, 9 Dec 2014 14:02:11 +0100 Subject: [PATCH 1/4] added some hiera integration --- manifests/init.pp | 15 ++++++++++++++- manifests/params.pp | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index f569627..257ec7a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -264,7 +264,9 @@ $log_dir = params_lookup( 'log_dir' ), $log_file = params_lookup( 'log_file' ), $port = params_lookup( 'port' ), - $protocol = params_lookup( 'protocol' ) + $protocol = params_lookup( 'protocol' ), + $grants = params_lookup( 'grants' ), + $users = params_lookup( 'users' ) ) inherits mysql::params { $bool_source_dir_purge=any2bool($source_dir_purge) @@ -415,6 +417,17 @@ include $mysql::my_class } + ### Create instances for integration with Hiera + if $grants != {} { + validate_hash($grants) + create_resources(mysql::grant, $grants) + } + + if $users != {} { + validate_hash($users) + create_resources(mysql::user, $users) + } + ### Provide puppi data, if enabled ( puppi => true ) if $mysql::bool_puppi == true { diff --git a/manifests/params.pp b/manifests/params.pp index 4092f1e..c630de3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -125,5 +125,7 @@ $puppi_helper = 'standard' $debug = false $audit_only = false + $grants = {} + $users = {} } From cb9778a7e062dceb869a7913383883f91d7234c9 Mon Sep 17 00:00:00 2001 From: Markus Burger Date: Tue, 9 Dec 2014 15:13:34 +0100 Subject: [PATCH 2/4] switched from require to include to break the dependency cycle --- manifests/grant.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/grant.pp b/manifests/grant.pp index b211801..f4616d1 100644 --- a/manifests/grant.pp +++ b/manifests/grant.pp @@ -49,7 +49,7 @@ ) { if $remote_host == '' { - require mysql + include mysql } $dbname = $mysql_db ? { From c2ca2c5993d872f22a090c9af33cd06568af4ce1 Mon Sep 17 00:00:00 2001 From: Marco Peterseil Date: Wed, 11 Mar 2015 10:32:36 +0100 Subject: [PATCH 3/4] break cyclic dependency --- manifests/password.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/password.pp b/manifests/password.pp index 6f89efd..1d5fdef 100644 --- a/manifests/password.pp +++ b/manifests/password.pp @@ -6,7 +6,7 @@ class mysql::password { # Load the variables used in this module. Check the params.pp file - require mysql + include mysql require mysql::params if ! defined(File['/root/.my.cnf']) { From 437b6b388e8b8f1bf84f8e7b91a1550c9bab6beb Mon Sep 17 00:00:00 2001 From: Markus Burger Date: Thu, 12 Mar 2015 12:51:38 +0100 Subject: [PATCH 4/4] convert the static root.my.cnf.erb template into a variable to allow better customization --- manifests/init.pp | 1 + manifests/params.pp | 1 + manifests/password.pp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 257ec7a..9e7f917 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -223,6 +223,7 @@ # class mysql ( $root_password = params_lookup( 'root_password' ), + $root_cnf_template = params_lookup( 'root_cnf_template' ), $password_salt = params_lookup( 'password_salt' ), $my_class = params_lookup( 'my_class' ), $source = params_lookup( 'source' ), diff --git a/manifests/params.pp b/manifests/params.pp index c630de3..db7a697 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -16,6 +16,7 @@ ### Module specific parameters $root_password = '' + $root_cnf_template = 'mysql/root.my.cnf.erb' $password_salt = '' ### Application related parameters diff --git a/manifests/password.pp b/manifests/password.pp index 1d5fdef..18bc9af 100644 --- a/manifests/password.pp +++ b/manifests/password.pp @@ -16,7 +16,7 @@ mode => '0400', owner => $mysql::config_file_owner, group => $mysql::config_file_group, - content => template('mysql/root.my.cnf.erb'), + content => template($mysql::root_cnf_template), # replace => false, # require => Exec['mysql_root_password'], }