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.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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
  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. interface 'internal'
  64. url internal_designate_endpoint.to_s
  65. region region
  66. connection_params connection_params
  67. end
  68. # Register Service Project
  69. openstack_project service_project_name do
  70. connection_params connection_params
  71. end
  72. # Register Service User
  73. openstack_user service_user do
  74. role_name service_role
  75. project_name service_project_name
  76. domain_name service_domain_name
  77. password service_pass
  78. connection_params connection_params
  79. action [:create, :grant_role]
  80. end