]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/manifests/resource/service_identity.pp
Update to Kilo
[dsa-puppet.git] / 3rdparty / modules / keystone / manifests / resource / service_identity.pp
1 #
2 # Copyright (C) 2014 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 # == Definition: keystone::resource::service_identity
19 #
20 # This resource configures Keystone resources for an OpenStack service.
21 #
22 # == Parameters:
23 #
24 # [*password*]
25 #   Password to create for the service user;
26 #   string; required
27 #
28 # [*auth_name*]
29 #   The name of the service user;
30 #   string; optional; default to the $title of the resource, i.e. 'nova'
31 #
32 # [*service_name*]
33 #   Name of the service;
34 #   string; required
35 #
36 # [*service_type*]
37 #   Type of the service;
38 #   string; required
39 #
40 # [*service_description*]
41 #   Description of the service;
42 #   string; optional: default to '$name service'
43 #
44 # [*public_url*]
45 #   Public endpoint URL;
46 #   string; required
47 #
48 # [*internal_url*]
49 #   Internal endpoint URL;
50 #   string; required
51 #
52 # [*admin_url*]
53 #   Admin endpoint URL;
54 #   string; required
55 #
56 # [*region*]
57 #   Endpoint region;
58 #   string; optional: default to 'RegionOne'
59 #
60 # [*tenant*]
61 #   Service tenant;
62 #   string; optional: default to 'services'
63 #
64 # [*ignore_default_tenant*]
65 #   Ignore setting the default tenant value when the user is created.
66 #   string; optional: default to false
67 #
68 # [*roles*]
69 #   List of roles;
70 #   string; optional: default to ['admin']
71 #
72 # [*email*]
73 #   Service email;
74 #   string; optional: default to '$auth_name@localhost'
75 #
76 # [*configure_endpoint*]
77 #   Whether to create the endpoint.
78 #   string; optional: default to True
79 #
80 # [*configure_user*]
81 #   Whether to create the user.
82 #   string; optional: default to True
83 #
84 # [*configure_user_role*]
85 #   Whether to create the user role.
86 #   string; optional: default to True
87 #
88 # [*configure_service*]
89 #   Whether to create the service.
90 #   string; optional: default to True
91 #
92 # [*user_domain*]
93 #   (Optional) Domain for $auth_name
94 #   Defaults to undef (use the keystone server default domain)
95 #
96 # [*project_domain*]
97 #   (Optional) Domain for $tenant (project)
98 #   Defaults to undef (use the keystone server default domain)
99 #
100 # [*default_domain*]
101 #   (Optional) Domain for $auth_name and $tenant (project)
102 #   If keystone_user_domain is not specified, use $keystone_default_domain
103 #   If keystone_project_domain is not specified, use $keystone_default_domain
104 #   Defaults to undef
105 #
106 define keystone::resource::service_identity(
107   $admin_url             = false,
108   $internal_url          = false,
109   $password              = false,
110   $public_url            = false,
111   $service_type          = false,
112   $auth_name             = $name,
113   $configure_endpoint    = true,
114   $configure_user        = true,
115   $configure_user_role   = true,
116   $configure_service     = true,
117   $email                 = "${name}@localhost",
118   $region                = 'RegionOne',
119   $service_name          = undef,
120   $service_description   = "${name} service",
121   $tenant                = 'services',
122   $ignore_default_tenant = false,
123   $roles                 = ['admin'],
124   $user_domain           = undef,
125   $project_domain        = undef,
126   $default_domain        = undef,
127 ) {
128   if $service_name == undef {
129     $service_name_real = $auth_name
130   } else {
131     $service_name_real = $service_name
132   }
133
134   if $user_domain == undef {
135     $user_domain_real = $default_domain
136   } else {
137     $user_domain_real = $user_domain
138   }
139
140   if $configure_user {
141     if $user_domain_real {
142       # We have to use ensure_resource here and hope for the best, because we have
143       # no way to know if the $user_domain is the same domain passed as the
144       # $default_domain parameter to class keystone.
145       ensure_resource('keystone_domain', $user_domain_real, {
146         'ensure'  => 'present',
147         'enabled' => true,
148       })
149     }
150     ensure_resource('keystone_user', $auth_name, {
151       'ensure'                => 'present',
152       'enabled'               => true,
153       'password'              => $password,
154       'email'                 => $email,
155       'tenant'                => $tenant,
156       'ignore_default_tenant' => $ignore_default_tenant,
157       'domain'                => $user_domain_real,
158     })
159   }
160
161   if $configure_user_role {
162     ensure_resource('keystone_user_role', "${auth_name}@${tenant}", {
163       'ensure' => 'present',
164       'roles'  => $roles,
165     })
166   }
167
168   if $configure_service {
169     ensure_resource('keystone_service', $service_name_real, {
170       'ensure'      => 'present',
171       'type'        => $service_type,
172       'description' => $service_description,
173     })
174   }
175
176   if $configure_endpoint {
177     ensure_resource('keystone_endpoint', "${region}/${service_name_real}", {
178       'ensure'       => 'present',
179       'public_url'   => $public_url,
180       'admin_url'    => $admin_url,
181       'internal_url' => $internal_url,
182     })
183   }
184 }