]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/manifests/resource/service_identity.pp
try with modules from master
[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 # [*domain*]
73 #   User domain (keystone v3), not implemented yet.
74 #   string; optional: default to undef
75 #
76 # [*email*]
77 #   Service email;
78 #   string; optional: default to '$auth_name@localhost'
79 #
80 # [*configure_endpoint*]
81 #   Whether to create the endpoint.
82 #   string; optional: default to True
83 #
84 # [*configure_user*]
85 #   Whether to create the user.
86 #   string; optional: default to True
87 #
88 # [*configure_user_role*]
89 #   Whether to create the user role.
90 #   string; optional: default to True
91 #
92 # [*configure_service*]
93 #   Whether to create the service.
94 #   string; optional: default to True
95 #
96 define keystone::resource::service_identity(
97   $admin_url             = false,
98   $internal_url          = false,
99   $password              = false,
100   $public_url            = false,
101   $service_type          = false,
102   $auth_name             = $name,
103   $configure_endpoint    = true,
104   $configure_user        = true,
105   $configure_user_role   = true,
106   $configure_service     = true,
107   $domain                = undef,
108   $email                 = "${name}@localhost",
109   $region                = 'RegionOne',
110   $service_name          = undef,
111   $service_description   = "${name} service",
112   $tenant                = 'services',
113   $ignore_default_tenant = false,
114   $roles                 = ['admin'],
115 ) {
116
117   if $domain {
118     warning('Keystone domains are not yet managed by puppet-keystone.')
119   }
120
121   if $service_name == undef {
122     $service_name_real = $auth_name
123   } else {
124     $service_name_real = $service_name
125   }
126
127   if $configure_user {
128     ensure_resource('keystone_user', $auth_name, {
129       'ensure'                => 'present',
130       'enabled'               => true,
131       'password'              => $password,
132       'email'                 => $email,
133       'tenant'                => $tenant,
134       'ignore_default_tenant' => $ignore_default_tenant,
135     })
136   }
137
138   if $configure_user_role {
139     ensure_resource('keystone_user_role', "${auth_name}@${tenant}", {
140       'ensure' => 'present',
141       'roles'  => $roles,
142     })
143     if $configure_user {
144       Keystone_user[$auth_name] -> Keystone_user_role["${auth_name}@${tenant}"]
145     }
146   }
147
148   if $configure_service {
149     ensure_resource('keystone_service', $service_name_real, {
150       'ensure'      => 'present',
151       'type'        => $service_type,
152       'description' => $service_description,
153     })
154   }
155
156   if $configure_endpoint {
157     ensure_resource('keystone_endpoint', "${region}/${service_name_real}", {
158       'ensure'       => 'present',
159       'public_url'   => $public_url,
160       'admin_url'    => $admin_url,
161       'internal_url' => $internal_url,
162     })
163   }
164 }