apache_api.pp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #
  2. # Copyright (C) 2015 eNovance SAS <licensing@enovance.com>
  3. #
  4. # Author: Emilien Macchi <emilien.macchi@enovance.com>
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  7. # not use this file except in compliance with the License. You may obtain
  8. # a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15. # License for the specific language governing permissions and limitations
  16. # under the License.
  17. #
  18. # Class to serve Nova API and EC2 with apache mod_wsgi in place of nova-api and nova-api-ec2 services.
  19. #
  20. # Serving Nova API and Nova API EC2 from apache is the recommended way to go for production
  21. # because of limited performance for concurrent accesses.
  22. #
  23. # When using this class you should disable your nova-api and nova-api-ec2 service.
  24. #
  25. # == Parameters
  26. #
  27. # [*servername*]
  28. # The servername for the virtualhost.
  29. # Optional. Defaults to $::fqdn
  30. #
  31. # [*api_port*]
  32. # The port for Nova API service.
  33. # Optional. Defaults to 8774
  34. #
  35. # [*bind_host*]
  36. # The host/ip address Apache will listen on.
  37. # Optional. Defaults to undef (listen on all ip addresses).
  38. #
  39. # [*path*]
  40. # The prefix for the endpoint.
  41. # Optional. Defaults to '/'
  42. #
  43. # [*ssl*]
  44. # Use ssl ? (boolean)
  45. # Optional. Defaults to true
  46. #
  47. # [*workers*]
  48. # Number of WSGI workers to spawn.
  49. # Optional. Defaults to 1
  50. #
  51. # [*priority*]
  52. # (optional) The priority for the vhost.
  53. # Defaults to '10'
  54. #
  55. # [*threads*]
  56. # (optional) The number of threads for the vhost.
  57. # Defaults to $::os_workers
  58. #
  59. # [*wsgi_process_display_name*]
  60. # (optional) Name of the WSGI process display-name.
  61. # Defaults to undef
  62. #
  63. # [*ssl_cert*]
  64. # [*ssl_key*]
  65. # [*ssl_chain*]
  66. # [*ssl_ca*]
  67. # [*ssl_crl_path*]
  68. # [*ssl_crl*]
  69. # [*ssl_certs_dir*]
  70. # apache::vhost ssl parameters.
  71. # Optional. Default to apache::vhost 'ssl_*' defaults.
  72. #
  73. # == Dependencies
  74. #
  75. # requires Class['apache'] & Class['nova'] & Class['nova::api']
  76. #
  77. # == Examples
  78. #
  79. # include apache
  80. #
  81. # class { 'nova::wsgi::apache': }
  82. #
  83. class nova::wsgi::apache_api (
  84. $servername = $::fqdn,
  85. $api_port = 8774,
  86. $bind_host = undef,
  87. $path = '/',
  88. $ssl = true,
  89. $workers = 1,
  90. $ssl_cert = undef,
  91. $ssl_key = undef,
  92. $ssl_chain = undef,
  93. $ssl_ca = undef,
  94. $ssl_crl_path = undef,
  95. $ssl_crl = undef,
  96. $ssl_certs_dir = undef,
  97. $wsgi_process_display_name = undef,
  98. $threads = $::os_workers,
  99. $priority = '10',
  100. ) {
  101. include ::nova::params
  102. include ::apache
  103. include ::apache::mod::wsgi
  104. if $ssl {
  105. include ::apache::mod::ssl
  106. }
  107. if ! defined(Class[::nova::api]) {
  108. fail('::nova::api class must be declared in composition layer.')
  109. }
  110. warning('deploying Nova API in WSGI with Apache is not recommended by Nova team. See LP#1661360.')
  111. ::openstacklib::wsgi::apache { 'nova_api_wsgi':
  112. bind_host => $bind_host,
  113. bind_port => $api_port,
  114. group => 'nova',
  115. path => $path,
  116. priority => $priority,
  117. servername => $servername,
  118. ssl => $ssl,
  119. ssl_ca => $ssl_ca,
  120. ssl_cert => $ssl_cert,
  121. ssl_certs_dir => $ssl_certs_dir,
  122. ssl_chain => $ssl_chain,
  123. ssl_crl => $ssl_crl,
  124. ssl_crl_path => $ssl_crl_path,
  125. ssl_key => $ssl_key,
  126. threads => $threads,
  127. user => 'nova',
  128. workers => $workers,
  129. wsgi_daemon_process => 'nova-api',
  130. wsgi_process_display_name => $wsgi_process_display_name,
  131. wsgi_process_group => 'nova-api',
  132. wsgi_script_dir => $::nova::params::nova_wsgi_script_path,
  133. wsgi_script_file => 'nova-api',
  134. wsgi_script_source => $::nova::params::nova_api_wsgi_script_source,
  135. }
  136. }