1621d1bdb0abae3b085276ce5ad574bf15e4f0d7
[mirror/dsa-puppet.git] / 3rdparty / modules / cinder / manifests / keystone / auth.pp
1 # == Class: cinder::keystone::auth
2 #
3 # Configures Cinder user, service and endpoint in Keystone.
4 #
5 # === Parameters
6 #
7 # [*password*]
8 #   Password for Cinder user. Required.
9 #
10 # [*email*]
11 #   Email for Cinder user. Optional. Defaults to 'cinder@localhost'.
12 #
13 # [*auth_name*]
14 #   Username for Cinder service. Optional. Defaults to 'cinder'.
15 #
16 # [*auth_name_v2*]
17 #   Username for Cinder v2 service. Optional. Defaults to 'cinder2'.
18 #
19 # [*configure_endpoint*]
20 #   Should Cinder endpoint be configured? Optional. Defaults to 'true'.
21 #   API v1 endpoint should be enabled in Icehouse for compatibility with Nova.
22 #
23 # [*configure_endpoint_v2*]
24 #   Should Cinder v2 endpoint be configured? Optional. Defaults to 'true'.
25 #
26 # [*configure_user*]
27 #   Should the service user be configured? Optional. Defaults to 'true'.
28 #
29 # [*configure_user_role*]
30 #   Should the admin role be configured for the service user?
31 #   Optional. Defaults to 'true'.
32 #
33 # [*service_type*]
34 #    Type of service. Optional. Defaults to 'volume'.
35 #
36 # [*service_type_v2*]
37 #    Type of API v2 service. Optional. Defaults to 'volume2'.
38 #
39 # [*public_address*]
40 #    Public address for endpoint. Optional. Defaults to '127.0.0.1'.
41 #
42 # [*admin_address*]
43 #    Admin address for endpoint. Optional. Defaults to '127.0.0.1'.
44 #
45 # [*internal_address*]
46 #    Internal address for endpoint. Optional. Defaults to '127.0.0.1'.
47 #
48 # [*port*]
49 #    Port for endpoint. Optional. Defaults to '8776'.
50 #
51 # [*volume_version*]
52 #    Cinder API version. Optional. Defaults to 'v1'.
53 #
54 # [*region*]
55 #    Region for endpoint. Optional. Defaults to 'RegionOne'.
56 #
57 # [*tenant*]
58 #    Tenant for Cinder user. Optional. Defaults to 'services'.
59 #
60 # [*public_protocol*]
61 #    Protocol for public endpoint. Optional. Defaults to 'http'.
62 #
63 # [*internal_protocol*]
64 #    Protocol for internal endpoint. Optional. Defaults to 'http'.
65 #
66 # [*admin_protocol*]
67 #    Protocol for admin endpoint. Optional. Defaults to 'http'.
68 #
69 class cinder::keystone::auth (
70   $password,
71   $auth_name             = 'cinder',
72   $auth_name_v2          = 'cinderv2',
73   $email                 = 'cinder@localhost',
74   $tenant                = 'services',
75   $configure_endpoint    = true,
76   $configure_endpoint_v2 = true,
77   $configure_user        = true,
78   $configure_user_role   = true,
79   $service_type          = 'volume',
80   $service_type_v2       = 'volumev2',
81   $public_address        = '127.0.0.1',
82   $admin_address         = '127.0.0.1',
83   $internal_address      = '127.0.0.1',
84   $port                  = '8776',
85   $volume_version        = 'v1',
86   $region                = 'RegionOne',
87   $public_protocol       = 'http',
88   $admin_protocol        = 'http',
89   $internal_protocol     = 'http'
90 ) {
91
92   if $configure_user {
93     keystone_user { $auth_name:
94       ensure   => present,
95       password => $password,
96       email    => $email,
97       tenant   => $tenant,
98     }
99   }
100
101   if $configure_user_role {
102     Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'cinder-api' |>
103
104     keystone_user_role { "${auth_name}@${tenant}":
105       ensure => present,
106       roles  => 'admin',
107     }
108   }
109
110   keystone_service { $auth_name:
111     ensure      => present,
112     type        => $service_type,
113     description => 'Cinder Service',
114   }
115   keystone_service { $auth_name_v2:
116     ensure      => present,
117     type        => $service_type_v2,
118     description => 'Cinder Service v2',
119   }
120
121   if $configure_endpoint {
122     keystone_endpoint { "${region}/${auth_name}":
123       ensure       => present,
124       public_url   => "${public_protocol}://${public_address}:${port}/${volume_version}/%(tenant_id)s",
125       admin_url    => "${admin_protocol}://${admin_address}:${port}/${volume_version}/%(tenant_id)s",
126       internal_url => "${internal_protocol}://${internal_address}:${port}/${volume_version}/%(tenant_id)s",
127     }
128   }
129   if $configure_endpoint_v2 {
130     keystone_endpoint { "${region}/${auth_name_v2}":
131       ensure       => present,
132       public_url   => "${public_protocol}://${public_address}:${port}/v2/%(tenant_id)s",
133       admin_url    => "${admin_protocol}://${admin_address}:${port}/v2/%(tenant_id)s",
134       internal_url => "${internal_protocol}://${internal_address}:${port}/v2/%(tenant_id)s",
135     }
136   }
137 }