]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/manifests/service.pp
try with modules from master
[dsa-puppet.git] / 3rdparty / modules / keystone / manifests / service.pp
1 # == Class keystone::service
2 #
3 # Encapsulates the keystone service to a class.
4 # This allows resources that require keystone to
5 # require this class, which can optionally
6 # validate that the service can actually accept
7 # connections.
8 #
9 # === Parameters
10 #
11 # [*ensure*]
12 #   (optional) The desired state of the keystone service
13 #   Defaults to undef
14 #
15 # [*service_name*]
16 #   (optional) The name of the keystone service
17 #   Defaults to $::keystone::params::service_name
18 #
19 # [*enable*]
20 #   (optional) Whether to enable the keystone service
21 #   Defaults to true
22 #
23 # [*hasstatus*]
24 #   (optional) Whether the keystone service has status
25 #   Defaults to true
26 #
27 # [*hasrestart*]
28 #   (optional) Whether the keystone service has restart
29 #   Defaults to true
30 #
31 # [*provider*]
32 #   (optional) Provider for keystone service
33 #   Defaults to $::keystone::params::service_provider
34 #
35 # [*validate*]
36 #   (optional) Whether to validate the service is working after any service refreshes
37 #   Defaults to false
38 #
39 # [*admin_token*]
40 #   (optional) The admin token to use for validation
41 #   Defaults to undef
42 #
43 # [*admin_endpoint*]
44 #   (optional) The admin endpont to use for validation
45 #   Defaults to 'http://localhost:35357/v2.0'
46 #
47 # [*retries*]
48 #   (optional) Number of times to retry validation
49 #   Defaults to 10
50 #
51 # [*delay*]
52 #   (optional) Number of seconds between validation attempts
53 #   Defaults to 2
54 #
55 # [*insecure*]
56 #   (optional) Whether to validate keystone connections
57 #   using the --insecure option with keystone client.
58 #   Defaults to false
59 #
60 # [*cacert*]
61 #   (optional) Whether to validate keystone connections
62 #   using the specified argument with the --os-cacert option
63 #   with keystone client.
64 #   Defaults to undef
65 #
66 class keystone::service(
67   $ensure         = undef,
68   $service_name   = $::keystone::params::service_name,
69   $enable         = true,
70   $hasstatus      = true,
71   $hasrestart     = true,
72   $provider       = $::keystone::params::service_provider,
73   $validate       = false,
74   $admin_token    = undef,
75   $admin_endpoint = 'http://localhost:35357/v2.0',
76   $retries        = 10,
77   $delay          = 2,
78   $insecure       = false,
79   $cacert         = undef,
80 ) {
81   include ::keystone::params
82
83   service { 'keystone':
84     ensure     => $ensure,
85     name       => $service_name,
86     enable     => $enable,
87     hasstatus  => $hasstatus,
88     hasrestart => $hasrestart,
89     provider   => $provider
90   }
91
92   if $insecure {
93     $insecure_s = '--insecure'
94   } else {
95     $insecure_s = ''
96   }
97
98   if $cacert {
99     $cacert_s = "--os-cacert ${cacert}"
100   } else {
101     $cacert_s = ''
102   }
103
104   if $validate and $admin_token and $admin_endpoint {
105     $cmd = "openstack --os-auth-url ${admin_endpoint} --os-token ${admin_token} ${insecure_s} ${cacert_s} user list"
106     $catch = 'name'
107     exec { 'validate_keystone_connection':
108       path        => '/usr/bin:/bin:/usr/sbin:/sbin',
109       provider    => shell,
110       command     => $cmd,
111       subscribe   => Service['keystone'],
112       refreshonly => true,
113       tries       => $retries,
114       try_sleep   => $delay
115     }
116
117     Exec['validate_keystone_connection'] -> Keystone_user<||>
118     Exec['validate_keystone_connection'] -> Keystone_role<||>
119     Exec['validate_keystone_connection'] -> Keystone_tenant<||>
120     Exec['validate_keystone_connection'] -> Keystone_service<||>
121     Exec['validate_keystone_connection'] -> Keystone_endpoint<||>
122   }
123 }