config.pp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. # Class: nginx::config
  2. #
  3. # This module manages NGINX bootstrap and configuration
  4. #
  5. # Parameters:
  6. #
  7. # There are no default parameters for this class.
  8. #
  9. # Actions:
  10. #
  11. # Requires:
  12. #
  13. # Sample Usage:
  14. #
  15. # This class file is not called directly
  16. class nginx::config(
  17. $client_body_buffer_size = $nginx::params::nx_client_body_buffer_size,
  18. $client_body_temp_path = $nginx::params::nx_client_body_temp_path,
  19. $client_max_body_size = $nginx::params::nx_client_max_body_size,
  20. $confd_purge = $nginx::params::nx_confd_purge,
  21. $conf_dir = $nginx::params::nx_conf_dir,
  22. $conf_template = $nginx::params::nx_conf_template,
  23. $daemon_user = $nginx::params::nx_daemon_user,
  24. $events_use = $nginx::params::nx_events_use,
  25. $fastcgi_cache_inactive = $nginx::params::nx_fastcgi_cache_inactive,
  26. $fastcgi_cache_key = $nginx::params::nx_fastcgi_cache_key,
  27. $fastcgi_cache_keys_zone = $nginx::params::nx_fastcgi_cache_keys_zone,
  28. $fastcgi_cache_levels = $nginx::params::nx_fastcgi_cache_levels,
  29. $fastcgi_cache_max_size = $nginx::params::nx_fastcgi_cache_max_size,
  30. $fastcgi_cache_path = $nginx::params::nx_fastcgi_cache_path,
  31. $fastcgi_cache_use_stale = $nginx::params::nx_fastcgi_cache_use_stale,
  32. $gzip = $nginx::params::nx_gzip,
  33. $http_access_log = $nginx::params::nx_http_access_log,
  34. $http_cfg_append = $nginx::params::nx_http_cfg_append,
  35. $http_tcp_nodelay = $nginx::params::nx_http_tcp_nodelay,
  36. $http_tcp_nopush = $nginx::params::nx_http_tcp_nopush,
  37. $keepalive_timeout = $nginx::params::nx_keepalive_timeout,
  38. $logdir = $nginx::params::nx_logdir,
  39. $mail = $nginx::params::nx_mail,
  40. $multi_accept = $nginx::params::nx_multi_accept,
  41. $names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size,
  42. $names_hash_max_size = $nginx::params::nx_names_hash_max_size,
  43. $nginx_error_log = $nginx::params::nx_nginx_error_log,
  44. $pid = $nginx::params::nx_pid,
  45. $proxy_buffers = $nginx::params::nx_proxy_buffers,
  46. $proxy_buffer_size = $nginx::params::nx_proxy_buffer_size,
  47. $proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive,
  48. $proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone,
  49. $proxy_cache_levels = $nginx::params::nx_proxy_cache_levels,
  50. $proxy_cache_max_size = $nginx::params::nx_proxy_cache_max_size,
  51. $proxy_cache_path = $nginx::params::nx_proxy_cache_path,
  52. $proxy_conf_template = $nginx::params::nx_proxy_conf_template,
  53. $proxy_connect_timeout = $nginx::params::nx_proxy_connect_timeout,
  54. $proxy_headers_hash_bucket_size = $nginx::params::nx_proxy_headers_hash_bucket_size,
  55. $proxy_http_version = $nginx::params::nx_proxy_http_version,
  56. $proxy_read_timeout = $nginx::params::nx_proxy_read_timeout,
  57. $proxy_redirect = $nginx::params::nx_proxy_redirect,
  58. $proxy_send_timeout = $nginx::params::nx_proxy_send_timeout,
  59. $proxy_set_header = $nginx::params::nx_proxy_set_header,
  60. $proxy_temp_path = $nginx::params::nx_proxy_temp_path,
  61. $run_dir = $nginx::params::nx_run_dir,
  62. $sendfile = $nginx::params::nx_sendfile,
  63. $server_tokens = $nginx::params::nx_server_tokens,
  64. $spdy = $nginx::params::nx_spdy,
  65. $super_user = $nginx::params::nx_super_user,
  66. $temp_dir = $nginx::params::nx_temp_dir,
  67. $types_hash_bucket_size = $nginx::params::nx_types_hash_bucket_size,
  68. $types_hash_max_size = $nginx::params::nx_types_hash_max_size,
  69. $vhost_purge = $nginx::params::nx_vhost_purge,
  70. $worker_connections = $nginx::params::nx_worker_connections,
  71. $worker_processes = $nginx::params::nx_worker_processes,
  72. $worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile,
  73. $global_owner = $nginx::params::global_owner,
  74. $global_group = $nginx::params::global_group,
  75. $global_mode = $nginx::params::global_mode,
  76. $sites_available_owner = $nginx::params::sites_available_owner,
  77. $sites_available_group = $nginx::params::sites_available_group,
  78. $sites_available_mode = $nginx::params::sites_available_mode,
  79. ) inherits nginx::params {
  80. File {
  81. owner => $global_owner,
  82. group => $global_group,
  83. mode => $global_mode,
  84. }
  85. file { $conf_dir:
  86. ensure => directory,
  87. }
  88. file { "${conf_dir}/conf.d":
  89. ensure => directory,
  90. }
  91. if $confd_purge == true {
  92. File["${conf_dir}/conf.d"] {
  93. purge => true,
  94. recurse => true,
  95. }
  96. }
  97. file { "${conf_dir}/conf.mail.d":
  98. ensure => directory,
  99. }
  100. if $confd_purge == true {
  101. File["${conf_dir}/conf.mail.d"] {
  102. purge => true,
  103. recurse => true,
  104. }
  105. }
  106. file { "${conf_dir}/conf.d/vhost_autogen.conf":
  107. ensure => absent,
  108. }
  109. file { "${conf_dir}/conf.mail.d/vhost_autogen.conf":
  110. ensure => absent,
  111. }
  112. file {$run_dir:
  113. ensure => directory,
  114. }
  115. file {$client_body_temp_path:
  116. ensure => directory,
  117. owner => $daemon_user,
  118. }
  119. file {$proxy_temp_path:
  120. ensure => directory,
  121. owner => $daemon_user,
  122. }
  123. file { "${conf_dir}/sites-available":
  124. ensure => directory,
  125. owner => $sites_available_owner,
  126. group => $sites_available_group,
  127. mode => $sites_available_mode,
  128. }
  129. if $vhost_purge == true {
  130. File["${conf_dir}/sites-available"] {
  131. purge => true,
  132. recurse => true,
  133. }
  134. }
  135. file { "${conf_dir}/sites-enabled":
  136. ensure => directory,
  137. }
  138. if $vhost_purge == true {
  139. File["${conf_dir}/sites-enabled"] {
  140. purge => true,
  141. recurse => true,
  142. }
  143. }
  144. file { "${conf_dir}/sites-enabled/default":
  145. ensure => absent,
  146. }
  147. file { "${conf_dir}/nginx.conf":
  148. ensure => file,
  149. content => template($conf_template),
  150. }
  151. file { "${conf_dir}/conf.d/proxy.conf":
  152. ensure => file,
  153. content => template($proxy_conf_template),
  154. }
  155. file { "${conf_dir}/conf.d/default.conf":
  156. ensure => absent,
  157. }
  158. file { "${conf_dir}/conf.d/example_ssl.conf":
  159. ensure => absent,
  160. }
  161. file { "${temp_dir}/nginx.d":
  162. ensure => absent,
  163. purge => true,
  164. recurse => true,
  165. force => true,
  166. }
  167. file { "${temp_dir}/nginx.mail.d":
  168. ensure => absent,
  169. purge => true,
  170. recurse => true,
  171. force => true,
  172. }
  173. }