/mysql/manifests/params.pp

https://github.com/stribert/puppet-modules · Puppet · 255 lines · 163 code · 44 blank · 48 comment · 0 complexity · 8aace087e3ce832d939cb0ed60403690 MD5 · raw file

  1. # Class: mysql::params
  2. #
  3. # Sets internal variables and defaults for mysql module
  4. # This class is automatically loaded in all the classes that use the values set here
  5. #
  6. class mysql::params {
  7. ## DEFAULTS FOR VARIABLES USERS CAN SET
  8. # (Here are set the defaults, provide your custom variables externally)
  9. # (The default used is in the line with '')
  10. $mysql_random_password = fqdn_rand(100000000000)
  11. $root_password = $mysql_root_password ? {
  12. '' => "",
  13. auto => "$mysql_random_password",
  14. default => "$mysql_root_password",
  15. }
  16. $logfile = $operatingsystem ? {
  17. default => "/var/log/mysqld.log",
  18. }
  19. ## MODULE INTERNAL VARIABLES
  20. # (Modify to adapt to unsupported OSes)
  21. $packagename = $operatingsystem ? {
  22. default => "mysql-server",
  23. }
  24. $packagename_client = $operatingsystem ? {
  25. redhat => "mysql",
  26. centos => "mysql",
  27. default => "mysql-client",
  28. }
  29. $servicename = $operatingsystem ? {
  30. redhat => "mysqld",
  31. centos => "mysqld",
  32. default => "mysql",
  33. }
  34. $processname = $operatingsystem ? {
  35. default => "mysqld",
  36. }
  37. $hasstatus = $operatingsystem ? {
  38. debian => false,
  39. ubuntu => false,
  40. default => true,
  41. }
  42. $status = $operatingsystem ? {
  43. default => '/etc/init.d/mysql status',
  44. }
  45. $configfile = $operatingsystem ? {
  46. debian => "/etc/mysql/my.cnf",
  47. ubuntu => "/etc/mysql/my.cnf",
  48. default => "/etc/my.cnf",
  49. }
  50. $configfile_mode = $operatingsystem ? {
  51. default => "644",
  52. }
  53. $configfile_owner = $operatingsystem ? {
  54. default => "root",
  55. }
  56. $configfile_group = $operatingsystem ? {
  57. default => "root",
  58. }
  59. $configdir = $operatingsystem ? {
  60. default => "/etc/mysql/conf.d",
  61. }
  62. $initconfigfile = $operatingsystem ? {
  63. debian => "/etc/default/mysql",
  64. ubuntu => "/etc/default/mysql",
  65. default => "/etc/sysconfig/mysqld",
  66. }
  67. # Used by monitor class
  68. $pidfile = $operatingsystem ? {
  69. default => "/var/run/mysqld/mysqld.pid",
  70. }
  71. # Used by backup class
  72. $datadir = $operatingsystem ? {
  73. default => "/var/lib/mysql",
  74. }
  75. # Used by backup class - Provide the file name, if there's no dedicated dir
  76. $logdir = $operatingsystem ? {
  77. default => "/var/log/mysql",
  78. }
  79. # Used by monitor and firewall class
  80. # If you need to define additional ports, call them $protocol1/$port1 and add the relevant
  81. # parts in firewall.pp and monitor.pp
  82. $protocol = "tcp"
  83. $port = "3306"
  84. ## DEFAULTS FOR MONITOR CLASS
  85. # These are settings that influence the (optional) mysql::monitor class
  86. # You can define these variables or leave the defaults
  87. # The apparently complex variables assignements below follow this logic:
  88. # - If no user variable is set, a reasonable default is used
  89. # - If the user has set a host-wide variable (ex: $monitor_target ) that one is set
  90. # - The host-wide variable can be overriden by a module specific one (ex: $mysql_monitor_target)
  91. # How the monitor server refers to the monitor target
  92. $monitor_target_real = $mysql_monitor_target ? {
  93. '' => $monitor_target ? {
  94. '' => "${fqdn}",
  95. default => $monitor_target,
  96. },
  97. default => "$mysql_monitor_target",
  98. }
  99. # BaseUrl to access this host
  100. $monitor_baseurl_real = $mysql_monitor_baseurl ? {
  101. '' => $monitor_baseurl ? {
  102. '' => "http://${fqdn}",
  103. default => $monitor_baseurl,
  104. },
  105. default => "${mysql_monitor_baseurl}",
  106. }
  107. # Pattern to look for in the URL defined in mysql::monitor class
  108. $monitor_url_pattern = $mysql_monitor_url_pattern ? {
  109. '' => "OK",
  110. default => "${mysql_monitor_url_pattern}",
  111. }
  112. # If mysql port monitoring is enabled
  113. $monitor_port_enable = $mysql_monitor_port ? {
  114. '' => $monitor_port ? {
  115. '' => true,
  116. default => $monitor_port,
  117. },
  118. default => $mysql_monitor_port,
  119. }
  120. # If mysql url monitoring is enabled
  121. $monitor_url_enable = $mysql_monitor_url ? {
  122. '' => $monitor_url ? {
  123. '' => false,
  124. default => $monitor_url,
  125. },
  126. default => $mysql_monitor_url,
  127. }
  128. # If mysql process monitoring is enabled
  129. $monitor_process_enable = $mysql_monitor_process ? {
  130. '' => $monitor_process ? {
  131. '' => true,
  132. default => $monitor_process,
  133. },
  134. default => $mysql_monitor_process,
  135. }
  136. # If mysql plugin monitoring is enabled
  137. $monitor_plugin_enable = $mysql_monitor_plugin ? {
  138. '' => $monitor_plugin ? {
  139. '' => false,
  140. default => $monitor_plugin,
  141. },
  142. default => $mysql_monitor_plugin,
  143. }
  144. ## DEFAULTS FOR BACKUP CLASS
  145. # These are settings that influence the (optional) mysql::backup class
  146. # You can define these variables or leave the defaults
  147. # How the backup server refers to the backup target
  148. $backup_target_real = $mysql_backup_target ? {
  149. '' => $backup_target ? {
  150. '' => "${fqdn}",
  151. default => $backup_target,
  152. },
  153. default => "$mysql_backup_target",
  154. }
  155. # Frequency of backups
  156. $backup_frequency = $mysql_backup_frequency ? {
  157. '' => "daily",
  158. default => "$mysql_backup_frequency",
  159. }
  160. # If mysql data have to be backed up
  161. $backup_data_enable = $mysql_backup_data ? {
  162. '' => $backup_data ? {
  163. '' => true,
  164. default => $backup_data,
  165. },
  166. default => $mysql_backup_data,
  167. }
  168. # If mysql logs have to be backed up
  169. $backup_log_enable = $mysql_backup_log ? {
  170. '' => $backup_log ? {
  171. '' => true,
  172. default => $backup_log,
  173. },
  174. default => $mysql_backup_log,
  175. }
  176. ## DEFAULTS FOR FIREWALL CLASS
  177. # These are settings that influence the (optional) mysql::firewall class
  178. # You can define these variables or leave the defaults
  179. # Source IPs that can access this service - Use iptables friendly format
  180. $firewall_source_real = $mysql_firewall_source ? {
  181. '' => $firewall_source ? {
  182. '' => "0.0.0.0/0",
  183. default => $firewall_source,
  184. },
  185. default => "$mysql_firewall_source",
  186. }
  187. # Destination IP to use for this host (Default facter's $ipaddress)
  188. $firewall_destination_real = $mysql_firewall_destination ? {
  189. '' => $firewall_destination ? {
  190. '' => "${ipaddress}",
  191. default => $firewall_destination,
  192. },
  193. default => "$mysql_firewall_destination",
  194. }
  195. ## FILE SERVING SOURCE
  196. # Sets the correct source for static files
  197. # In order to provide files from different sources without modifying the module
  198. # you can override the default source path setting the variable $base_source
  199. # Ex: $base_source="puppet://ip.of.fileserver" or $base_source="puppet://$servername/myprojectmodule"
  200. # What follows automatically manages the new source standard (with /modules/) from 0.25
  201. case $base_source {
  202. '': {
  203. $general_base_source = $puppetversion ? {
  204. /(^0.25)/ => "puppet:///modules",
  205. /(^0.)/ => "puppet://$servername",
  206. default => "puppet:///modules",
  207. }
  208. }
  209. default: { $general_base_source=$base_source }
  210. }
  211. }