init.pp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. # Class: nginx
  2. #
  3. # This module manages NGINX.
  4. #
  5. # Parameters:
  6. #
  7. # Actions:
  8. #
  9. # Requires:
  10. # puppetlabs-stdlib - https://github.com/puppetlabs/puppetlabs-stdlib
  11. #
  12. # Packaged NGINX
  13. # - RHEL: EPEL or custom package
  14. # - Debian/Ubuntu: Default Install or custom package
  15. # - SuSE: Default Install or custom package
  16. #
  17. # stdlib
  18. # - puppetlabs-stdlib module >= 0.1.6
  19. # - plugin sync enabled to obtain the anchor type
  20. #
  21. # Sample Usage:
  22. #
  23. # The module works with sensible defaults:
  24. #
  25. # node default {
  26. # include nginx
  27. # }
  28. class nginx (
  29. ### START Nginx Configuration ###
  30. $client_body_buffer_size = undef,
  31. $client_body_temp_path = undef,
  32. $client_max_body_size = undef,
  33. $events_use = undef,
  34. $fastcgi_cache_inactive = undef,
  35. $fastcgi_cache_key = undef,
  36. $fastcgi_cache_keys_zone = undef,
  37. $fastcgi_cache_levels = undef,
  38. $fastcgi_cache_max_size = undef,
  39. $fastcgi_cache_path = undef,
  40. $fastcgi_cache_use_stale = undef,
  41. $gzip = undef,
  42. $http_cfg_append = undef,
  43. $http_tcp_nodelay = undef,
  44. $http_tcp_nopush = undef,
  45. $keepalive_timeout = undef,
  46. $mail = undef,
  47. $multi_accept = undef,
  48. $names_hash_bucket_size = undef,
  49. $names_hash_max_size = undef,
  50. $proxy_buffers = undef,
  51. $proxy_buffer_size = undef,
  52. $proxy_cache_inactive = undef,
  53. $proxy_cache_keys_zone = undef,
  54. $proxy_cache_levels = undef,
  55. $proxy_cache_max_size = undef,
  56. $proxy_cache_path = undef,
  57. $proxy_connect_timeout = undef,
  58. $proxy_headers_hash_bucket_size = undef,
  59. $proxy_http_version = undef,
  60. $proxy_read_timeout = undef,
  61. $proxy_redirect = undef,
  62. $proxy_send_timeout = undef,
  63. $proxy_set_header = undef,
  64. $sendfile = undef,
  65. $server_tokens = undef,
  66. $spdy = undef,
  67. $types_hash_bucket_size = undef,
  68. $types_hash_max_size = undef,
  69. $worker_connections = undef,
  70. $worker_processes = undef,
  71. $worker_rlimit_nofile = undef,
  72. ### END Nginx Configuration
  73. ### START Module/App Configuration ###
  74. $confd_purge = undef,
  75. $conf_dir = undef,
  76. $daemon_user = undef,
  77. $global_owner = undef,
  78. $global_group = undef,
  79. $global_mode = undef,
  80. $logdir = undef,
  81. $log_format = undef,
  82. $http_access_log = undef,
  83. $nginx_error_log = undef,
  84. $pid = undef,
  85. $proxy_temp_path = undef,
  86. $root_group = undef,
  87. $run_dir = undef,
  88. $sites_available_owner = undef,
  89. $sites_available_group = undef,
  90. $sites_available_mode = undef,
  91. $super_user = undef,
  92. $temp_dir = undef,
  93. $vhost_purge = undef,
  94. # Primary Templates
  95. $conf_template = undef,
  96. $proxy_conf_template = undef,
  97. ### END Module/App Configuration ###
  98. ### START Package Configuration ###
  99. $package_ensure = present,
  100. $package_name = $::nginx::params::package_name,
  101. $package_source = 'nginx',
  102. $package_flavor = undef,
  103. $manage_repo = $::nginx::params::manage_repo,
  104. ### END Package Configuration ###
  105. ### START Service Configuation ###
  106. $configtest_enable = false,
  107. $service_ensure = running,
  108. $service_flags = undef,
  109. $service_restart = '/etc/init.d/nginx configtest && /etc/init.d/nginx restart',
  110. $service_name = undef,
  111. ### END Service Configuration ###
  112. ### START Hiera Lookups ###
  113. $geo_mappings = {},
  114. $string_mappings = {},
  115. $nginx_locations = {},
  116. $nginx_mailhosts = {},
  117. $nginx_upstreams = {},
  118. $nginx_vhosts = {},
  119. $nginx_vhosts_defaults = {},
  120. ### END Hiera Lookups ###
  121. ) inherits ::nginx::params {
  122. ### DEPRECATION WARNING ###
  123. ###
  124. ### During the transition from the params pattern -> puppet-module-data,
  125. ### we need a graceful way to notify the consumer that the pattern is
  126. ### changing, and point them toward docs on how to transition.
  127. ###
  128. ### Once we hit 1.0, this whole block goes away.
  129. ###
  130. ### Please note: as a contributor to this module, no Pulls will be accepted
  131. ### that do add additional parameters to this class. Get on this puppet-module-data
  132. ### level!
  133. ### This block makes me sad, but what can you do.... we need to do this
  134. ### migration the Right Way(tm) -- JDF
  135. if $client_body_buffer_size or
  136. $client_body_temp_path or
  137. $client_max_body_size or
  138. $confd_purge or
  139. $conf_dir or
  140. $conf_template or
  141. $daemon_user or
  142. $events_use or
  143. $fastcgi_cache_inactive or
  144. $fastcgi_cache_key or
  145. $fastcgi_cache_keys_zone or
  146. $fastcgi_cache_levels or
  147. $fastcgi_cache_max_size or
  148. $fastcgi_cache_path or
  149. $fastcgi_cache_use_stale or
  150. $gzip or
  151. $http_access_log or
  152. $http_cfg_append or
  153. $http_tcp_nodelay or
  154. $http_tcp_nopush or
  155. $keepalive_timeout or
  156. $logdir or
  157. $log_format or
  158. $mail or
  159. $multi_accept or
  160. $names_hash_bucket_size or
  161. $names_hash_max_size or
  162. $nginx_error_log or
  163. $pid or
  164. $proxy_buffers or
  165. $proxy_buffer_size or
  166. $proxy_cache_inactive or
  167. $proxy_cache_keys_zone or
  168. $proxy_cache_levels or
  169. $proxy_cache_max_size or
  170. $proxy_cache_path or
  171. $proxy_conf_template or
  172. $proxy_connect_timeout or
  173. $proxy_headers_hash_bucket_size or
  174. $proxy_http_version or
  175. $proxy_read_timeout or
  176. $proxy_redirect or
  177. $proxy_send_timeout or
  178. $proxy_set_header or
  179. $proxy_temp_path or
  180. $run_dir or
  181. $sendfile or
  182. $server_tokens or
  183. $spdy or
  184. $super_user or
  185. $temp_dir or
  186. $types_hash_bucket_size or
  187. $types_hash_max_size or
  188. $vhost_purge or
  189. $worker_connections or
  190. $worker_processes or
  191. $worker_rlimit_nofile or
  192. $global_owner or
  193. $global_group or
  194. $global_mode or
  195. $sites_available_owner or
  196. $sites_available_group or
  197. $sites_available_mode {
  198. include ::nginx::notice::config
  199. }
  200. ### END DEPRECATION WARNING ###
  201. class { '::nginx::package':
  202. package_name => $package_name,
  203. package_source => $package_source,
  204. package_ensure => $package_ensure,
  205. package_flavor => $package_flavor,
  206. notify => Class['::nginx::service'],
  207. manage_repo => $manage_repo,
  208. }
  209. ## This `if` statement is here in the event a user cannot use
  210. ## Hiera based parameter overrides. Will not be here in 1.0 release
  211. if !defined(Class['::nginx::config']) {
  212. class { '::nginx::config':
  213. client_body_buffer_size => $client_body_buffer_size,
  214. client_body_temp_path => $client_body_temp_path,
  215. client_max_body_size => $client_max_body_size,
  216. confd_purge => $confd_purge,
  217. conf_dir => $conf_dir,
  218. conf_template => $conf_template,
  219. daemon_user => $daemon_user,
  220. events_use => $events_use,
  221. fastcgi_cache_inactive => $fastcgi_cache_inactive,
  222. fastcgi_cache_key => $fastcgi_cache_key,
  223. fastcgi_cache_keys_zone => $fastcgi_cache_keys_zone,
  224. fastcgi_cache_levels => $fastcgi_cache_levels,
  225. fastcgi_cache_max_size => $fastcgi_cache_max_size,
  226. fastcgi_cache_path => $fastcgi_cache_path,
  227. fastcgi_cache_use_stale => $fastcgi_cache_use_stale,
  228. gzip => $gzip,
  229. http_access_log => $http_access_log,
  230. http_cfg_append => $http_cfg_append,
  231. http_tcp_nodelay => $http_tcp_nodelay,
  232. http_tcp_nopush => $http_tcp_nopush,
  233. keepalive_timeout => $keepalive_timeout,
  234. log_dir => $logdir,
  235. log_format => $log_format,
  236. mail => $mail,
  237. multi_accept => $multi_accept,
  238. names_hash_bucket_size => $names_hash_bucket_size,
  239. names_hash_max_size => $names_hash_max_size,
  240. nginx_error_log => $nginx_error_log,
  241. pid => $pid,
  242. proxy_buffers => $proxy_buffers,
  243. proxy_buffer_size => $proxy_buffer_size,
  244. proxy_cache_inactive => $proxy_cache_inactive,
  245. proxy_cache_keys_zone => $proxy_cache_keys_zone,
  246. proxy_cache_levels => $proxy_cache_levels,
  247. proxy_cache_max_size => $proxy_cache_max_size,
  248. proxy_cache_path => $proxy_cache_path,
  249. proxy_conf_template => $proxy_conf_template,
  250. proxy_connect_timeout => $proxy_connect_timeout,
  251. proxy_headers_hash_bucket_size => $proxy_headers_hash_bucket_size,
  252. proxy_http_version => $proxy_http_version,
  253. proxy_read_timeout => $proxy_read_timeout,
  254. proxy_redirect => $proxy_redirect,
  255. proxy_send_timeout => $proxy_send_timeout,
  256. proxy_set_header => $proxy_set_header,
  257. proxy_temp_path => $proxy_temp_path,
  258. run_dir => $run_dir,
  259. sendfile => $sendfile,
  260. server_tokens => $server_tokens,
  261. spdy => $spdy,
  262. super_user => $super_user,
  263. temp_dir => $temp_dir,
  264. types_hash_bucket_size => $types_hash_bucket_size,
  265. types_hash_max_size => $types_hash_max_size,
  266. vhost_purge => $vhost_purge,
  267. worker_connections => $worker_connections,
  268. worker_processes => $worker_processes,
  269. worker_rlimit_nofile => $worker_rlimit_nofile,
  270. global_owner => $global_owner,
  271. global_group => $global_group,
  272. global_mode => $global_mode,
  273. sites_available_owner => $sites_available_owner,
  274. sites_available_group => $sites_available_group,
  275. sites_available_mode => $sites_available_mode,
  276. }
  277. }
  278. Class['::nginx::package'] -> Class['::nginx::config'] ~> Class['::nginx::service']
  279. class { '::nginx::service':
  280. configtest_enable => $configtest_enable,
  281. service_ensure => $service_ensure,
  282. service_restart => $service_restart,
  283. service_name => $service_name,
  284. service_flags => $service_flags,
  285. }
  286. create_resources('::nginx::resource::upstream', $nginx_upstreams)
  287. create_resources('::nginx::resource::vhost', $nginx_vhosts, $nginx_vhosts_defaults)
  288. create_resources('::nginx::resource::location', $nginx_locations)
  289. create_resources('::nginx::resource::mailhost', $nginx_mailhosts)
  290. create_resources('::nginx::resource::map', $string_mappings)
  291. create_resources('::nginx::resource::geo', $geo_mappings)
  292. # Allow the end user to establish relationships to the "main" class
  293. # and preserve the relationship to the implementation classes through
  294. # a transitive relationship to the composite class.
  295. anchor{ 'nginx::begin':
  296. before => Class['::nginx::package'],
  297. notify => Class['::nginx::service'],
  298. }
  299. anchor { 'nginx::end':
  300. require => Class['::nginx::service'],
  301. }
  302. }