]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/manifests/service.pp
63c148d3b958d13ec2979f581d324ca44add92eb
[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 'running'
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
37 # after any service refreshes
38 # Defaults to false
39 #
40 # [*admin_token*]
41 # (optional) The admin token to use for validation
42 # Defaults to undef
43 #
44 # [*admin_endpoint*]
45 # (optional) The admin endpont to use for validation
46 # Defaults to 'http://localhost:35357/v2.0'
47 #
48 # [*retries*]
49 # (optional) Number of times to retry validation
50 # Defaults to 10
51 #
52 # [*delay*]
53 # (optional) Number of seconds between validation attempts
54 # Defaults to 2
55 #
56 # [*insecure*]
57 # (optional) Whether to validate keystone connections
58 # using the --insecure option with keystone client.
59 # Defaults to false
60 #
61 # [*cacert*]
62 # (optional) Whether to validate keystone connections
63 # using the specified argument with the --os-cacert option
64 # with keystone client.
65 # Defaults to undef
66 #
67 class keystone::service(
68   $ensure         = 'running',
69   $service_name   = $::keystone::params::service_name,
70   $enable         = true,
71   $hasstatus      = true,
72   $hasrestart     = true,
73   $provider       = $::keystone::params::service_provider,
74   $validate       = false,
75   $admin_token    = undef,
76   $admin_endpoint = 'http://localhost:35357/v2.0',
77   $retries        = 10,
78   $delay          = 2,
79   $insecure       = false,
80   $cacert         = undef,
81 ) {
82   include keystone::params
83
84   service { 'keystone':
85     ensure     => $ensure,
86     name       => $service_name,
87     enable     => $enable,
88     hasstatus  => $hasstatus,
89     hasrestart => $hasrestart,
90     provider   => $provider
91   }
92
93   if $insecure {
94     $insecure_s = '--insecure'
95   } else {
96     $insecure_s = ''
97   }
98
99   if $cacert {
100     $cacert_s = "--os-cacert ${cacert}"
101   } else {
102     $cacert_s = ''
103   }
104
105   if $validate and $admin_token and $admin_endpoint {
106     $cmd = "keystone --os-endpoint ${admin_endpoint} --os-token ${admin_token} ${insecure_s} ${cacert_s} user-list"
107     $catch = 'name'
108     exec { 'validate_keystone_connection':
109       path          => '/usr/bin:/bin:/usr/sbin:/sbin',
110       provider      => shell,
111       command       => $cmd,
112       subscribe     => Service['keystone'],
113       refreshonly   => true,
114       tries         => $retries,
115       try_sleep     => $delay
116     }
117
118     Exec['validate_keystone_connection'] -> Keystone_user<||>
119     Exec['validate_keystone_connection'] -> Keystone_role<||>
120     Exec['validate_keystone_connection'] -> Keystone_tenant<||>
121     Exec['validate_keystone_connection'] -> Keystone_service<||>
122     Exec['validate_keystone_connection'] -> Keystone_endpoint<||>
123   }
124 }