Chef Cookbook - OpenStack DNS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

identity_registration.rb 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # encoding: UTF-8
  2. #
  3. # Cookbook Name:: openstack-dns
  4. # Recipe:: identity_registration
  5. #
  6. # Copyright 2017, x-ion GmbH
  7. #
  8. # Licensed under the Apache License, Version 2.0 (the "License");
  9. # you may not use this file except in compliance with the License.
  10. # You may obtain a copy of the License at
  11. #
  12. # http://www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. #
  20. require 'uri'
  21. class ::Chef::Recipe # rubocop:disable Documentation
  22. include ::Openstack
  23. end
  24. identity_admin_endpoint = admin_endpoint 'identity'
  25. auth_url = ::URI.decode identity_admin_endpoint.to_s
  26. internal_designate_endpoint = internal_endpoint 'dns-api'
  27. public_designate_endpoint = public_endpoint 'dns-api'
  28. service_pass = get_password 'service', 'openstack-dns'
  29. service_project_name = node['openstack']['dns']['conf']['keystone_authtoken']['project_name']
  30. service_user = node['openstack']['dns']['conf']['keystone_authtoken']['username']
  31. service_role = node['openstack']['dns']['service_role']
  32. service_type = 'dns'
  33. service_name = 'designate'
  34. service_domain_name = node['openstack']['dns']['conf']['keystone_authtoken']['user_domain_name']
  35. admin_user = node['openstack']['identity']['admin_user']
  36. admin_pass = get_password 'user', node['openstack']['identity']['admin_user']
  37. admin_project = node['openstack']['identity']['admin_project']
  38. admin_domain = node['openstack']['identity']['admin_domain_name']
  39. region = node['openstack']['region']
  40. connection_params = {
  41. openstack_auth_url: "#{auth_url}/auth/tokens",
  42. openstack_username: admin_user,
  43. openstack_api_key: admin_pass,
  44. openstack_project_name: admin_project,
  45. openstack_domain_name: admin_domain
  46. }
  47. # Register DNS Service
  48. openstack_service service_name do
  49. type service_type
  50. connection_params connection_params
  51. end
  52. # Register DNS Public-Endpoint
  53. openstack_endpoint service_type do
  54. service_name service_name
  55. interface 'public'
  56. url public_designate_endpoint.to_s
  57. region region
  58. connection_params connection_params
  59. end
  60. # Register DNS Internal-Endpoint
  61. openstack_endpoint service_type do
  62. service_name service_name
  63. url internal_designate_endpoint.to_s
  64. region region
  65. connection_params connection_params
  66. end
  67. # Register Service Project
  68. openstack_project service_project_name do
  69. connection_params connection_params
  70. end
  71. # Register Service User
  72. openstack_user service_user do
  73. project_name service_project_name
  74. domain_name service_domain_name
  75. password service_pass
  76. connection_params connection_params
  77. end
  78. ## Grant Service role to Service User for Service Project ##
  79. openstack_user service_user do
  80. role_name service_role
  81. project_name service_project_name
  82. connection_params connection_params
  83. action :grant_role
  84. end