diff --git a/manifests/config.pp b/manifests/config.pp index ff642d6d..22a9fbc6 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -6,6 +6,8 @@ $config_settings = $proxysql::config_settings $proxy_config_file = $proxysql::proxy_config_file + $split_config = $proxysql::split_config + if $proxysql::manage_config_file { file { 'proxysql-config-file': ensure => file, @@ -22,7 +24,7 @@ file { 'proxysql-proxy-config-file': ensure => file, path => $proxysql::proxy_config_file, - content => template('proxysql/proxysql_proxy.cnf.erb'), + content => epp('proxysql/proxysql_proxy.cnf.epp', { config_settings => $config_settings }), mode => '0640', owner => $proxysql::sys_owner, group => $proxysql::sys_group, diff --git a/templates/proxysql.cnf.erb b/templates/proxysql.cnf.erb index b38cc4ac..bb946a32 100644 --- a/templates/proxysql.cnf.erb +++ b/templates/proxysql.cnf.erb @@ -40,7 +40,7 @@ end <% else -%> -<% if scope.lookupvar('::proxysql::split_config') == false -%> +<% if @split_config == false -%> <%= k %> = ( <% v.each do |ki, vi| @@ -67,6 +67,6 @@ end end -%> -<% if scope.lookupvar('::proxysql::split_config') == true -%> +<% if @split_config == true -%> @include "<%= @proxy_config_file %>" <% end -%> diff --git a/templates/proxysql_proxy.cnf.epp b/templates/proxysql_proxy.cnf.epp new file mode 100644 index 00000000..5297a5c5 --- /dev/null +++ b/templates/proxysql_proxy.cnf.epp @@ -0,0 +1,18 @@ +<%- | Hash $config_settings | -%> +<% $config_settings.each |$key, $value| { -%> +<% if $key == "mysql_servers" { -%> +<%= $key %> = (<% if $value != {} { -%><%= $value %><% } -%>) +<% } -%> +<% if $key == "mysql_users" { -%> +<%= $key %> = (<% if $value != {} { -%><%= $value %><% } -%>) +<% } -%> +<% if $key == "mysql_query_rules" { -%> +<%= $key %> = (<% if $value != {} { -%><%= $value %><% } -%>) +<% } -%> +<% if $key == "scheduler" { -%> +<%= $key %> = (<% if $value != {} { -%><%= $value %><% } -%>) +<% } -%> +<% if $key == "mysql_replication_hostgroups" { -%> +<%= $key %> = (<% if $value != {} { -%><%= $value %><% } -%>) +<% } -%> +<% } -%> diff --git a/templates/proxysql_proxy.cnf.erb b/templates/proxysql_proxy.cnf.erb deleted file mode 100644 index 7413a743..00000000 --- a/templates/proxysql_proxy.cnf.erb +++ /dev/null @@ -1,56 +0,0 @@ -<% -default_handler = Proc.new do |k, v| - if v.is_a?(Integer) || v.is_a?(TrueClass) || v.is_a?(FalseClass) --%> - <%= k %> = <%= v %> -<% - else --%> - <%= k %> = "<%= v %>" -<% - end -end -hash_handler = Proc.new do |k, v| - if v.is_a?(Hash) --%> - { -<% - v.map do |ki, vi| - hash_handler.call(ki, vi) - end --%> - }<% - else - default_handler.call(k, v) - end -end -@config_settings.map do |k, v| - if v.is_a?(Hash) - if k == 'admin_variables' || k == 'mysql_variables' --%> -<% - else --%> -<%= k %> = ( -<% - v.each do |ki, vi| - if vi.is_a?(Hash) - hash_handler.call(ki, vi) - else - default_handler.call(ki, vi) - end - if v.keys.index(ki) < v.size - 1 --%> -, -<% - end - end --%> - -) - -<% - end - end -end --%>