init.pp 12 KB

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