summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Filion <gabster@lelutin.ca>2013-12-05 16:19:52 -0500
committerGabriel Filion <gabster@lelutin.ca>2013-12-05 16:19:52 -0500
commitfc6458e9e438a76220af57edaef54ccf3228f6f7 (patch)
tree1766dff731857b2a5ba0ff9d95efb2460d009860
parent6d9a84686734e598249410bf60eedf2d7fd2e521 (diff)
manage configuration snippets in a conf.d directory
this should make it easier to override values from my.cnf, or to set other values that aren't in the main config file.
-rw-r--r--manifests/conf.pp36
-rw-r--r--manifests/server/base.pp8
-rw-r--r--templates/conf.erb9
3 files changed, 53 insertions, 0 deletions
diff --git a/manifests/conf.pp b/manifests/conf.pp
new file mode 100644
index 0000000..069c012
--- /dev/null
+++ b/manifests/conf.pp
@@ -0,0 +1,36 @@
+# $config needs to be a hash of key => value pairs.
+#
+# values in config are output as key = value, except when the value is empty;
+# then just key is output. if you need to output an empty value in the form
+# key = value, then you can specify empty quotes as the value (see example).
+#
+# mysql::conf { 'test':
+# ensure => present,
+# section => 'mysqld',
+# config => {
+# table_cache => '15000',
+# skip_slave => '',
+# something => '""',
+# }
+# }
+#
+# This will generate the following contents:
+# [mysqld]
+# skip_slave
+# something = ""
+# table_cache = 15000
+#
+define mysql::conf (
+ $section,
+ $config,
+ $ensure = present
+) {
+
+ include mysql::server::base
+
+ file { "/etc/mysql/conf.d/${name}.cnf":
+ ensure => $ensure,
+ content => template('mysql/conf.erb'),
+ }
+
+}
diff --git a/manifests/server/base.pp b/manifests/server/base.pp
index 14f3c1b..4a29591 100644
--- a/manifests/server/base.pp
+++ b/manifests/server/base.pp
@@ -88,4 +88,12 @@ class mysql::server::base {
Mysql_user<<| tag == "mysql_${::fqdn}" |>>
Mysql_grant<<| tag == "mysql_${::fqdn}" |>>
}
+
+ file { '/etc/mysql/conf.d':
+ ensure => directory,
+ owner => 'root',
+ group => 0,
+ mode => '0755',
+ }
+
}
diff --git a/templates/conf.erb b/templates/conf.erb
new file mode 100644
index 0000000..c7e332a
--- /dev/null
+++ b/templates/conf.erb
@@ -0,0 +1,9 @@
+# THIS FILE IS MANAGED BY PUPPET
+[<%= @section -%>]
+<% @config.each do |key, value| -%>
+<% if value != '' -%>
+<%= key -%> = <%= value %>
+<% else -%>
+<%= key %>
+<% end -%>
+<% end %>