api.pp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. # == Class: nova::metadata::novajoin::api
  2. #
  3. # The nova::metadata::novajoin::api class encapsulates an
  4. # IPA Nova Join API service.
  5. #
  6. # === Parameters
  7. #
  8. # [*nova_password*]
  9. # (required) Password for the nova service user.
  10. #
  11. # [*transport_url*]
  12. # (required) Transport URL for notifier service to talk to
  13. # the messaging queue.
  14. #
  15. # [*bind_address*]
  16. # (optional) IP address for novajoin server to listen
  17. # Defaults to '127.0.0.1'
  18. #
  19. # [*api_paste_config*]
  20. # (optional) Filename for the paste deploy file.
  21. # Defaults to '/etc/nova/join-api-paste.ini'.
  22. #
  23. # [*auth_strategy*]
  24. # (optional) Strategy to use for authentication.
  25. # Defaults to 'keystone'.
  26. #
  27. # [*auth_type*]
  28. # (optional) Authentication type.
  29. # Defaults to 'password'.
  30. #
  31. # [*cacert*]
  32. # (optional) CA cert file.
  33. # Defaults to '/etc/ipa/ca.crt'.
  34. #
  35. # [*connect_retries*]
  36. # (optional) Number of connection retries to IPA.
  37. # Defaults to 1.
  38. #
  39. # [*debug*]
  40. # (optional) Set log level to debug.
  41. # Defaults to false.
  42. #
  43. # [*enabled*]
  44. # (optional) Whether to enable services.
  45. # Defaults to true.
  46. #
  47. # [*enable_ipa_client_install*]
  48. # (optional) whether to perform ipa_client_install
  49. # Defaults to true.
  50. #
  51. # [*ensure_package*]
  52. # (optional) The state of novajoin packages.
  53. # Defaults to 'present'
  54. #
  55. # [*ipa_domain*]
  56. # (optional) IPA domain
  57. # Reads the value from /etc/ipa/default.conf if not defined.
  58. #
  59. # [*join_listen_port*]
  60. # (optional) Port for novajoin service to listen on.
  61. # Defaults to 9090
  62. #
  63. # [*keystone_auth_url*]
  64. # (optional) auth_url for the keystone instance.
  65. # Defaults to 'http:://127.0.0.1:35357'
  66. #
  67. # [*keytab*]
  68. # (optional) Kerberos client keytab file.
  69. # Defaults to '/etc/nova/krb5.keytab'
  70. #
  71. # [*log_dir*]
  72. # (optional) log directory.
  73. # Defaults to '/var/log/novajoin'
  74. #
  75. # [*manage_service*]
  76. # (optional) If Puppet should manage service startup / shutdown.
  77. # Defaults to true.
  78. #
  79. # [*nova_user*]
  80. # (optional) User that nova services run as.
  81. # Defaults to 'nova'
  82. #
  83. # [*project_domain_name*]
  84. # (optional) Domain name containing project (for nova auth).
  85. # Defaults to 'default'
  86. #
  87. # [*project_name*]
  88. # (optional) Project name (for nova auth).
  89. # Defaults to 'service'
  90. #
  91. # [*user_domain_id*]
  92. # (optional) Domain for nova user.
  93. # Defaults to 'default'
  94. #
  95. class nova::metadata::novajoin::api (
  96. $nova_password,
  97. $transport_url,
  98. $bind_address = '127.0.0.1',
  99. $api_paste_config = '/etc/nova/join-api-paste.ini',
  100. $auth_strategy = $::os_service_default,
  101. $auth_type = 'password',
  102. $cacert = '/etc/ipa/ca.crt',
  103. $connect_retries = $::os_service_default,
  104. $debug = $::os_service_default,
  105. $enabled = true,
  106. $enable_ipa_client_install = true,
  107. $ensure_package = 'present',
  108. $ipa_domain = undef,
  109. $join_listen_port = $::os_service_default,
  110. $keystone_auth_url = 'http://127.0.0.1:35357/',
  111. $keytab = '/etc/nova/krb5.keytab',
  112. $log_dir = '/var/log/novajoin',
  113. $manage_service = true,
  114. $nova_user = 'nova',
  115. $project_domain_name = 'default',
  116. $project_name = 'service',
  117. $user_domain_id = 'default',
  118. ) {
  119. case $::osfamily {
  120. 'RedHat': {
  121. $package_name = 'python-novajoin'
  122. $service_name = 'novajoin-server'
  123. $notify_service_name = 'novajoin-notify'
  124. }
  125. default: {
  126. fail("Unsupported osfamily: ${::osfamily} operatingsystem")
  127. }
  128. } # Case $::osfamily
  129. if $enable_ipa_client_install {
  130. require ::ipaclient
  131. }
  132. package { 'python-novajoin':
  133. ensure => $ensure_package,
  134. name => $package_name,
  135. tag => ['openstack', 'novajoin-package'],
  136. }
  137. if $ipa_domain != undef {
  138. novajoin_config {
  139. 'DEFAULT/domain': value => $ipa_domain;
  140. }
  141. }
  142. novajoin_config {
  143. 'DEFAULT/join_listen': value => $bind_address;
  144. 'DEFAULT/api_paste_config': value => $api_paste_config;
  145. 'DEFAULT/auth_strategy': value => $auth_strategy;
  146. 'DEFAULT/cacert': value => $cacert;
  147. 'DEFAULT/connect_retries': value => $connect_retries;
  148. 'DEFAULT/debug': value => $debug;
  149. 'DEFAULT/join_listen_port': value => $join_listen_port;
  150. 'DEFAULT/keytab': value => $keytab;
  151. 'DEFAULT/log_dir': value => $log_dir;
  152. 'DEFAULT/transport_url': value => $transport_url;
  153. 'service_credentials/auth_type': value => $auth_type;
  154. 'service_credentials/auth_url': value => $keystone_auth_url;
  155. 'service_credentials/password': value => $nova_password;
  156. 'service_credentials/username': value => $nova_user;
  157. 'service_credentials/project_name': value => $project_name;
  158. 'service_credentials/user_domain_id': value => $user_domain_id;
  159. 'service_credentials/project_domain_name':
  160. value => $project_domain_name;
  161. }
  162. if $manage_service {
  163. if $enabled {
  164. $service_ensure = 'running'
  165. } else {
  166. $service_ensure = 'stopped'
  167. }
  168. }
  169. service { 'novajoin-server':
  170. ensure => $service_ensure,
  171. name => $service_name,
  172. enable => $enabled,
  173. hasstatus => true,
  174. hasrestart => true,
  175. tag => 'openstack',
  176. }
  177. service { 'novajoin-notify':
  178. ensure => $service_ensure,
  179. name => $notify_service_name,
  180. enable => $enabled,
  181. hasstatus => true,
  182. hasrestart => true,
  183. tag => 'openstack',
  184. }
  185. exec { 'get-service-user-keytab':
  186. command => "/usr/bin/kinit -kt /etc/krb5.keytab && ipa-getkeytab -s `grep xmlrpc_uri /etc/ipa/default.conf | cut -d/ -f3` \
  187. -p nova/${::fqdn} -k ${keytab}",
  188. creates => $keytab,
  189. require => Package['python-novajoin']
  190. }
  191. ensure_resource('file', $keytab, { owner => $nova_user, require => Exec['get-service-user-keytab'] })
  192. Novajoin_config<||> ~> Service<| title == 'nova-api'|>
  193. Exec['get-service-user-keytab'] ~> Service['novajoin-server']
  194. Exec['get-service-user-keytab'] ~> Service['novajoin-notify']
  195. Exec['get-service-user-keytab'] ~> Service<| title == 'nova-api'|>
  196. }