]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/nova/manifests/keystone/auth.pp
try again, with puppetforge modules, correctly included now
[dsa-puppet.git] / 3rdparty / modules / nova / manifests / keystone / auth.pp
1 # == Class: nova::keystone::auth
2 #
3 # Creates nova endpoints and service account in keystone
4 #
5 # === Parameters:
6 #
7 # [*password*]
8 #   Password to create for the service user
9 #
10 # [*auth_name*]
11 #   (optional) The name of the nova service user
12 #   Defaults to 'nova'
13 #
14 # [*auth_name_v3*]
15 #   (optional) The name of the nova v3 service user
16 #   Defaults to 'novav3'
17 #
18 # [*service_name*]
19 #   (optional) Name of the service.
20 #   Defaults to the value of auth_name.
21 #
22 # [*service_name_v3*]
23 #   (optional) Name of the v3 service.
24 #   Defaults to the value of auth_name_v3.
25 #
26 # [*public_address*]
27 #   (optional) The public nova-api endpoint
28 #   Defaults to '127.0.0.1'
29 #
30 # [*admin_address*]
31 #   (optional) The admin nova-api endpoint
32 #   Defaults to '127.0.0.1'
33 #
34 # [*internal_address*]
35 #   (optional) The internal nova-api endpoint
36 #   Defaults to '127.0.0.1'
37 #
38 # [*compute_port*]
39 #   (optional) The port to use for the compute endpoint
40 #   Defaults to '8774'
41 #
42 # [*ec2_port*]
43 #   (optional) The port to use for the ec2 endpoint
44 #   Defaults to '8773'
45 #
46 # [*compute_version*]
47 #   (optional) The version of the compute api to put in the endpoint
48 #   Defaults to 'v2'
49 #
50 # [*region*]
51 #   (optional) The region in which to place the endpoints
52 #   Defaults to 'RegionOne'
53 #
54 # [*tenant*]
55 #   (optional) The tenant to use for the nova service user
56 #   Defaults to 'services'
57 #
58 # [*email*]
59 #   (optional) The email address for the nova service user
60 #   Defaults to 'nova@localhost'
61 #
62 # [*configure_ec2_endpoint*]
63 #   (optional) Whether to create an ec2 endpoint
64 #   Defaults to true
65 #
66 # [*configure_endpoint*]
67 #   (optional) Whether to create the endpoint.
68 #   Defaults to true
69 #
70 # [*configure_endpoint_v3*]
71 #   (optional) Whether to create the v3 endpoint.
72 #   Defaults to true
73 #
74 # [*configure_user*]
75 #   (optional) Whether to create the service user.
76 #   Defaults to true
77 #
78 # [*configure_user_role*]
79 #   (optional) Whether to configure the admin role for the service user.
80 #   Defaults to true
81 #
82 # [*cinder*]
83 #   (optional) Deprecated and has no effect
84 #   Defaults to undef
85 #
86 # [*public_protocol*]
87 #   (optional) Protocol to use for the public endpoint. Can be http or https.
88 #   Defaults to 'http'
89 #
90 # [*admin_protocol*]
91 #   Protocol for admin endpoints. Defaults to 'http'.
92 #
93 # [*internal_protocol*]
94 #   Protocol for internal endpoints. Defaults to 'http'.
95 #
96 class nova::keystone::auth(
97   $password,
98   $auth_name              = 'nova',
99   $auth_name_v3           = 'novav3',
100   $service_name           = undef,
101   $service_name_v3        = undef,
102   $public_address         = '127.0.0.1',
103   $admin_address          = '127.0.0.1',
104   $internal_address       = '127.0.0.1',
105   $compute_port           = '8774',
106   $ec2_port               = '8773',
107   $compute_version        = 'v2',
108   $region                 = 'RegionOne',
109   $tenant                 = 'services',
110   $email                  = 'nova@localhost',
111   $configure_ec2_endpoint = true,
112   $cinder                 = undef,
113   $public_protocol        = 'http',
114   $configure_endpoint     = true,
115   $configure_endpoint_v3  = true,
116   $configure_user         = true,
117   $configure_user_role    = true,
118   $admin_protocol         = 'http',
119   $internal_protocol      = 'http'
120 ) {
121
122   if $cinder != undef {
123     warning('The cinder parameter is deprecated and has no effect.')
124   }
125
126   if $service_name == undef {
127     $real_service_name = $auth_name
128   } else {
129     $real_service_name = $service_name
130   }
131
132   if $service_name_v3 == undef {
133     $real_service_name_v3 = $auth_name_v3
134   } else {
135     $real_service_name_v3 = $service_name_v3
136   }
137
138   Keystone_endpoint["${region}/${real_service_name}"] ~> Service <| name == 'nova-api' |>
139
140   if $configure_user {
141     keystone_user { $auth_name:
142       ensure   => present,
143       password => $password,
144       email    => $email,
145       tenant   => $tenant,
146     }
147   }
148
149   if $configure_user_role {
150     keystone_user_role { "${auth_name}@${tenant}":
151       ensure => present,
152       roles  => 'admin',
153     }
154   }
155
156   keystone_service { $real_service_name:
157     ensure      => present,
158     type        => 'compute',
159     description => 'Openstack Compute Service',
160   }
161
162   if $configure_endpoint {
163     keystone_endpoint { "${region}/${real_service_name}":
164       ensure       => present,
165       public_url   => "${public_protocol}://${public_address}:${compute_port}/${compute_version}/%(tenant_id)s",
166       admin_url    => "${admin_protocol}://${admin_address}:${compute_port}/${compute_version}/%(tenant_id)s",
167       internal_url => "${internal_protocol}://${internal_address}:${compute_port}/${compute_version}/%(tenant_id)s",
168     }
169   }
170
171   if $configure_endpoint_v3 {
172     keystone_service { $real_service_name_v3:
173       ensure      => present,
174       type        => 'computev3',
175       description => 'Openstack Compute Service v3',
176     }
177     keystone_endpoint { "${region}/${real_service_name_v3}":
178       ensure       => present,
179       public_url   => "${public_protocol}://${public_address}:${compute_port}/v3",
180       admin_url    => "${admin_protocol}://${admin_address}:${compute_port}/v3",
181       internal_url => "${internal_protocol}://${internal_address}:${compute_port}/v3",
182     }
183   }
184
185   if $configure_ec2_endpoint {
186     keystone_service { "${real_service_name}_ec2":
187       ensure      => present,
188       type        => 'ec2',
189       description => 'EC2 Service',
190     }
191     keystone_endpoint { "${region}/${real_service_name}_ec2":
192       ensure       => present,
193       public_url   => "${public_protocol}://${public_address}:${ec2_port}/services/Cloud",
194       admin_url    => "${admin_protocol}://${admin_address}:${ec2_port}/services/Admin",
195       internal_url => "${internal_protocol}://${internal_address}:${ec2_port}/services/Cloud",
196     }
197   }
198 }