add stackforge/openstacklib to 3rdparty
[mirror/dsa-puppet.git] / 3rdparty / modules / openstacklib / manifests / service_validation.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: openstacklib::service_validation
19 #
20 # This resource does service validation for an OpenStack service.
21 #
22 # == Parameters:
23 #
24 # [*command*]
25 # Command to run for validating the service;
26 # string; required
27 #
28 # [*service_name*]
29 # The name of the service to validate;
30 # string; optional; default to the $title of the resource, i.e. 'nova-api'
31 #
32 # [*path*]
33 # The path of the command to validate the service;
34 # string; optional; default to '/usr/bin:/bin:/usr/sbin:/sbin'
35 #
36 # [*provider*]
37 # The provider to use for the exec command;
38 # string; optional; default to 'shell'
39 #
40 # [*tries*]
41 # Number of times to retry validation;
42 # string; optional; default to '10'
43 #
44 # [*try_sleep*]
45 # Number of seconds between validation attempts;
46 # string; optional; default to '2'
47 #
48 define openstacklib::service_validation(
49   $command,
50   $service_name = $name,
51   $path         = '/usr/bin:/bin:/usr/sbin:/sbin',
52   $provider     = shell,
53   $tries        = '10',
54   $try_sleep    = '2',
55 ) {
56
57   exec { "execute ${service_name} validation":
58     path      => $path,
59     provider  => $provider,
60     command   => $command,
61     tries     => $tries,
62     try_sleep => $try_sleep,
63   }
64
65   anchor { "create ${service_name} anchor":
66     require => Exec["execute ${service_name} validation"],
67   }
68
69 }