init.pp 11 KB

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