]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/manifests/roles/admin.pp
Update to Kilo
[dsa-puppet.git] / 3rdparty / modules / keystone / manifests / roles / admin.pp
1 # == Class: keystone::roles::admin
2 #
3 # This class implements some reasonable admin defaults for keystone.
4 #
5 # It creates the following keystone objects:
6 #   * service tenant (tenant used by all service users)
7 #   * "admin" tenant (defaults to "openstack")
8 #   * admin user (that defaults to the "admin" tenant)
9 #   * admin role
10 #   * adds admin role to admin user on the "admin" tenant
11 #
12 # === Parameters:
13 #
14 # [*email*]
15 #   The email address for the admin. Required.
16 #
17 # [*password*]
18 #   The admin password. Required.
19 #
20 # [*admin_roles*]
21 #   The list of the roles with admin privileges. Optional.
22 #   Defaults to ['admin'].
23 #
24 # [*admin_tenant*]
25 #   The name of the tenant to be used for admin privileges. Optional.
26 #   Defaults to openstack.
27 #
28 # [*service_tenant*]
29 #   The name of service keystone tenant. Optional.
30 #   Defaults to 'services'.
31 #
32 # [*admin*]
33 #   Admin user. Optional.
34 #   Defaults to admin.
35 #
36 # [*ignore_default_tenant*]
37 #   Ignore setting the default tenant value when the user is created. Optional.
38 #   Defaults to false.
39 #
40 # [*admin_tenant_desc*]
41 #   Optional. Description for admin tenant,
42 #   Defaults to 'admin tenant'
43 #
44 # [*service_tenant_desc*]
45 #   Optional. Description for admin tenant,
46 #   Defaults to 'Tenant for the openstack services'
47 #
48 # [*configure_user*]
49 #   Optional. Should the admin user be created?
50 #   Defaults to 'true'.
51 #
52 # [*configure_user_role*]
53 #   Optional. Should the admin role be configured for the admin user?
54 #   Defaults to 'true'.
55 #
56 # [*admin_user_domain*]
57 #   Optional.  Domain of the admin user
58 #   Defaults to undef (undef will resolve to class keystone $default_domain)
59 #
60 # [*admin_project_domain*]
61 #   Optional.  Domain of the admin tenant
62 #   Defaults to undef (undef will resolve to class keystone $default_domain)
63 #
64 # [*service_project_domain*]
65 #   Optional.  Domain for $service_tenant
66 #   Defaults to undef (undef will resolve to class keystone $default_domain)
67 #
68 # == Dependencies
69 # == Examples
70 # == Authors
71 #
72 #   Dan Bode dan@puppetlabs.com
73 #
74 # == Copyright
75 #
76 # Copyright 2012 Puppetlabs Inc, unless otherwise noted.
77 #
78 class keystone::roles::admin(
79   $email,
80   $password,
81   $admin                  = 'admin',
82   $admin_tenant           = 'openstack',
83   $admin_roles            = ['admin'],
84   $service_tenant         = 'services',
85   $ignore_default_tenant  = false,
86   $admin_tenant_desc      = 'admin tenant',
87   $service_tenant_desc    = 'Tenant for the openstack services',
88   $configure_user         = true,
89   $configure_user_role    = true,
90   $admin_user_domain      = undef,
91   $admin_project_domain   = undef,
92   $service_project_domain = undef,
93 ) {
94
95   if $service_project_domain {
96     if $service_project_domain != $admin_user_domain {
97       if $service_project_domain != $admin_project_domain {
98         keystone_domain { $service_project_domain:
99           ensure  => present,
100           enabled => true,
101         }
102       }
103     }
104   }
105
106   if $admin_project_domain {
107     if $admin_project_domain != $admin_user_domain {
108       if $service_project_domain != $admin_project_domain {
109         keystone_domain { $admin_project_domain:
110           ensure  => present,
111           enabled => true,
112         }
113       }
114     }
115   }
116
117   if $admin_user_domain {
118     if $admin_project_domain != $admin_user_domain {
119       if $service_project_domain != $admin_user_domain {
120         keystone_domain { $admin_user_domain:
121           ensure  => present,
122           enabled => true,
123         }
124       }
125     }
126   }
127
128   keystone_tenant { $service_tenant:
129     ensure      => present,
130     enabled     => true,
131     description => $service_tenant_desc,
132     domain      => $service_project_domain,
133   }
134   keystone_tenant { $admin_tenant:
135     ensure      => present,
136     enabled     => true,
137     description => $admin_tenant_desc,
138     domain      => $admin_project_domain,
139   }
140   keystone_role { 'admin':
141     ensure => present,
142   }
143
144   if $configure_user {
145     keystone_user { $admin:
146       ensure                => present,
147       enabled               => true,
148       tenant                => $admin_tenant,
149       email                 => $email,
150       password              => $password,
151       domain                => $admin_user_domain,
152       ignore_default_tenant => $ignore_default_tenant,
153     }
154   }
155
156   if $configure_user_role {
157     keystone_user_role { "${admin}@${admin_tenant}":
158       ensure => present,
159       roles  => $admin_roles,
160     }
161   }
162
163 }