Puppet Class: cloud::storage::rbd::pools

Defined in:
manifests/storage/rbd/pools.pp

Overview

Copyright © 2013 eNovance SAS <licensing@enovance.com>

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Parameters:

  • setup_pools (Any) (defaults to: false)
  • glance_rbd_user (Any) (defaults to: $os_params::glance_rbd_user)
  • glance_rbd_pool (Any) (defaults to: $os_params::glance_rbd_pool)
  • cinder_rbd_user (Any) (defaults to: $os_params::cinder_rbd_user)
  • cinder_rbd_pool (Any) (defaults to: $os_params::cinder_rbd_pool)
  • nova_rbd_pool (Any) (defaults to: $os_params::nova_rbd_pool)
  • cinder_backup_user (Any) (defaults to: $os_params::cinder_rbd_backup_user)
  • cinder_backup_pool (Any) (defaults to: $os_params::cinder_rbd_backup_pool)
  • ceph_fsid (Any) (defaults to: $os_params::ceph_fsid)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'manifests/storage/rbd/pools.pp', line 16

class cloud::storage::rbd::pools(
  $setup_pools          = false,
  $glance_rbd_user      = $os_params::glance_rbd_user,
  $glance_rbd_pool      = $os_params::glance_rbd_pool,
  $cinder_rbd_user      = $os_params::cinder_rbd_user,
  $cinder_rbd_pool      = $os_params::cinder_rbd_pool,
  $nova_rbd_pool        = $os_params::nova_rbd_pool,
  $cinder_backup_user   = $os_params::cinder_rbd_backup_user,
  $cinder_backup_pool   = $os_params::cinder_rbd_backup_pool,
  $ceph_fsid            = $os_params::ceph_fsid,
) {

  if $setup_pools {
    if !empty($::ceph_admin_key) {

      exec { "create_${glance_rbd_pool}_pool":
        command => "rados mkpool ${glance_rbd_pool}",
        unless  => "rados lspools | grep -sq ${glance_rbd_pool}",
      }

      exec { "create_${glance_rbd_pool}_user_and_key":
        command => "ceph auth get-or-create client.${glance_rbd_user} mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=${glance_rbd_pool}'",
        unless  => "ceph auth list 2> /dev/null | egrep -sq '^client.${glance_rbd_user}$'",
        require => Exec["create_${glance_rbd_pool}_pool"];
      }

      exec { "create_${cinder_rbd_pool}_pool":
        command => "rados mkpool ${cinder_rbd_pool}",
        unless  => "/usr/bin/rados lspools | grep -sq ${cinder_rbd_pool}",
      }

      exec { "create_${cinder_rbd_pool}_user_and_key":
        # TODO: point PG num with a cluster variable
        command => "ceph auth get-or-create client.${cinder_rbd_user} mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rx pool=${glance_rbd_pool}, allow rwx pool=${cinder_rbd_pool}, allow rwx pool=${nova_rbd_pool}'",
        unless  => "ceph auth list 2> /dev/null | egrep -sq '^client.${cinder_rbd_user}$'",
        require => Exec["create_${cinder_rbd_pool}_pool"];
      }

      # Note(EmilienM): We use the same keyring for Nova and Cinder.
      exec { "create_${nova_rbd_pool}_pool":
        command => "rados mkpool ${nova_rbd_pool}",
        unless  => "/usr/bin/rados lspools | grep -sq ${nova_rbd_pool}",
      }

      if $::ceph_keyring_glance {
        # NOTE(fc): Puppet needs to run a second time to enter this
        @@ceph::key { $glance_rbd_user:
          secret       => $::ceph_keyring_glance,
          keyring_path => "/etc/ceph/ceph.client.${glance_rbd_user}.keyring"
        }
        Ceph::Key <<| title == $cinder_rbd_user |>>
      }

      if $::ceph_keyring_cinder {
        # NOTE(fc): Puppet needs to run a second time to enter this
        @@ceph::key { $cinder_rbd_user:
          secret       => $::ceph_keyring_cinder,
          keyring_path => "/etc/ceph/ceph.client.${cinder_rbd_user}.keyring"
        }
        Ceph::Key <<| title == $cinder_rbd_user |>>
      }

      $clients = [$glance_rbd_user, $cinder_rbd_user]
      @@concat::fragment { 'ceph-clients-os':
        target  => '/etc/ceph/ceph.conf',
        order   => '95',
        content => template('cloud/storage/ceph/ceph-client.conf.erb')
      }

      @@file { '/etc/ceph/secret.xml':
        content => template('cloud/storage/ceph/secret-compute.xml.erb'),
        tag     => 'ceph_compute_secret_file',
      }

      @@exec { 'get_or_set_virsh_secret':
        command => 'virsh secret-define --file /etc/ceph/secret.xml',
        unless  => "virsh secret-list | tail -n +3 | cut -f1 -d' ' | grep -sq ${ceph_fsid}",
        tag     => 'ceph_compute_get_secret',
        require => [Package['libvirt-bin'],File['/etc/ceph/secret.xml']],
        notify  => Exec['set_secret_value_virsh'],
      }

      @@exec { 'set_secret_value_virsh':
        command      => "virsh secret-set-value --secret ${ceph_fsid} --base64 ${::ceph_keyring_cinder}",
        tag          => 'ceph_compute_set_secret',
        refreshonly  =>  true,
      }

    } # !empty($::ceph_admin_key)
  } # if setup pools
}