try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / cinder / manifests / backend / rbd.pp
1 # == define: cinder::backend::rbd
2 #
3 # Setup Cinder to use the RBD driver.
4 # Compatible for multiple backends
5 #
6 # === Parameters
7 #
8 # [*rbd_pool*]
9 #   (required) Specifies the pool name for the block device driver.
10 #
11 # [*rbd_user*]
12 #   (required) A required parameter to configure OS init scripts and cephx.
13 #
14 # [*volume_backend_name*]
15 #   (optional) Allows for the volume_backend_name to be separate of $name.
16 #   Defaults to: $name
17 #
18 # [*rbd_ceph_conf*]
19 #   (optional) Path to the ceph configuration file to use
20 #   Defaults to '/etc/ceph/ceph.conf'
21 #
22 # [*rbd_flatten_volume_from_snapshot*]
23 #   (optional) Enable flatten volumes created from snapshots.
24 #   Defaults to false
25 #
26 # [*rbd_secret_uuid*]
27 #   (optional) A required parameter to use cephx.
28 #   Defaults to false
29 #
30 # [*volume_tmp_dir*]
31 #   (optional) Location to store temporary image files if the volume
32 #   driver does not write them directly to the volume
33 #   Defaults to false
34 #
35 # [*rbd_max_clone_depth*]
36 #   (optional) Maximum number of nested clones that can be taken of a
37 #   volume before enforcing a flatten prior to next clone.
38 #   A value of zero disables cloning
39 #   Defaults to '5'
40 #
41 # [*glance_api_version*]
42 #   (optional) DEPRECATED: Use cinder::glance Class instead.
43 #   Glance API version. (Defaults to '2')
44 #   Setting this parameter cause a duplicate resource declaration
45 #   with cinder::glance
46 #
47 define cinder::backend::rbd (
48   $rbd_pool,
49   $rbd_user,
50   $volume_backend_name              = $name,
51   $rbd_ceph_conf                    = '/etc/ceph/ceph.conf',
52   $rbd_flatten_volume_from_snapshot = false,
53   $rbd_secret_uuid                  = false,
54   $volume_tmp_dir                   = false,
55   $rbd_max_clone_depth              = '5',
56   # DEPRECATED PARAMETERS
57   $glance_api_version               = undef,
58 ) {
59
60   include cinder::params
61
62   if $glance_api_version {
63     warning('The glance_api_version parameter is deprecated, use glance_api_version of cinder::glance class instead.')
64   }
65
66   cinder_config {
67     "${name}/volume_backend_name":              value => $volume_backend_name;
68     "${name}/volume_driver":                    value => 'cinder.volume.drivers.rbd.RBDDriver';
69     "${name}/rbd_ceph_conf":                    value => $rbd_ceph_conf;
70     "${name}/rbd_user":                         value => $rbd_user;
71     "${name}/rbd_pool":                         value => $rbd_pool;
72     "${name}/rbd_max_clone_depth":              value => $rbd_max_clone_depth;
73     "${name}/rbd_flatten_volume_from_snapshot": value => $rbd_flatten_volume_from_snapshot;
74   }
75
76   if $rbd_secret_uuid {
77     cinder_config {"${name}/rbd_secret_uuid": value => $rbd_secret_uuid;}
78   } else {
79     cinder_config {"${name}/rbd_secret_uuid": ensure => absent;}
80   }
81
82   if $volume_tmp_dir {
83     cinder_config {"${name}/volume_tmp_dir": value => $volume_tmp_dir;}
84   } else {
85     cinder_config {"${name}/volume_tmp_dir": ensure => absent;}
86   }
87
88   case $::osfamily {
89     'Debian': {
90       $override_line    = "env CEPH_ARGS=\"--id ${rbd_user}\""
91       $override_match   = '^env CEPH_ARGS='
92     }
93     'RedHat': {
94       $override_line    = "export CEPH_ARGS=\"--id ${rbd_user}\""
95       $override_match   = '^export CEPH_ARGS='
96     }
97     default: {
98       fail("unsuported osfamily ${::osfamily}, currently Debian and Redhat are the only supported platforms")
99     }
100   }
101
102   # Creates an empty file if it doesn't yet exist
103   ensure_resource('file', $::cinder::params::ceph_init_override, {'ensure' => 'present'})
104
105   ensure_resource('file_line', 'set initscript env', {
106     line   => $override_line,
107     path   => $::cinder::params::ceph_init_override,
108     match  => $override_match,
109     notify => Service['cinder-volume']
110   })
111
112 }