Puppet Class: profile::ceph::client::rbd

Defined in:
modules/profile/manifests/ceph/client/rbd.pp

Overview

Class: profile::ceph::client:rbd

This profile will configure clients for connecting to Ceph rados block storage using the native kernel driver or librbd

Parameters:

  • enable_v2_messenger (Boolean) (defaults to: lookup('profile::ceph::client::rbd::enable_v2_messenger'))
  • mon_hosts (Hash[String,Hash]) (defaults to: lookup('profile::ceph::mon::hosts'))
  • cluster_network (Stdlib::IP::Address) (defaults to: lookup('profile::ceph::cluster_network'))
  • public_network (Stdlib::IP::Address) (defaults to: lookup('profile::ceph::public_network'))
  • data_dir (Stdlib::Unixpath) (defaults to: lookup('profile::ceph::data_dir'))
  • client_name (String) (defaults to: lookup('profile::ceph::client::rbd::client_name'))
  • fsid (String) (defaults to: lookup('profile::ceph::fsid'))
  • keydata (String) (defaults to: lookup('profile::ceph::client::rbd::keydata'))
  • keyfile_group (String) (defaults to: lookup('profile::ceph::client::rbd::keyfile_group'))
  • keyfile_owner (String) (defaults to: lookup('profile::ceph::client::rbd::keyfile_owner'))
  • libvirt_rbd_uuid (String) (defaults to: lookup('profile::ceph::client::rbd::libvirt_rbd_uuid'))


5
6
7
8
9
10
11
12
13
14
15
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
# File 'modules/profile/manifests/ceph/client/rbd.pp', line 5

class profile::ceph::client::rbd(
    Boolean             $enable_v2_messenger = lookup('profile::ceph::client::rbd::enable_v2_messenger'),
    Hash[String,Hash]   $mon_hosts           = lookup('profile::ceph::mon::hosts'),
    Stdlib::IP::Address $cluster_network     = lookup('profile::ceph::cluster_network'),
    Stdlib::IP::Address $public_network      = lookup('profile::ceph::public_network'),
    Stdlib::Unixpath    $data_dir            = lookup('profile::ceph::data_dir'),
    String              $client_name         = lookup('profile::ceph::client::rbd::client_name'),
    String              $fsid                = lookup('profile::ceph::fsid'),
    String              $keydata             = lookup('profile::ceph::client::rbd::keydata'),
    String              $keyfile_group       = lookup('profile::ceph::client::rbd::keyfile_group'),
    String              $keyfile_owner       = lookup('profile::ceph::client::rbd::keyfile_owner'),
    String              $libvirt_rbd_uuid    = lookup('profile::ceph::client::rbd::libvirt_rbd_uuid'),
) {

    class { 'ceph::common':
        home_dir => $data_dir,
    }

    class { 'ceph::config':
        cluster_network     => $cluster_network,
        enable_libvirt_rbd  => true,
        enable_v2_messenger => $enable_v2_messenger,
        fsid                => $fsid,
        mon_hosts           => $mon_hosts,
        public_network      => $public_network,
    }

    # The keydata used in this step is pre-created on one of the ceph mon hosts
    # typically with the 'ceph auth get-or-create' command
    file { "/etc/ceph/ceph.client.${client_name}.keyring":
        ensure    => present,
        mode      => '0440',
        owner     => $keyfile_owner,
        group     => $keyfile_group,
        content   => "[client.${client_name}]\n        key = ${keydata}\n",
        show_diff => false,
        require   => Package['ceph-common'],
    }
    #TODO libvirt dependency
    file { '/etc/ceph/libvirt-secret.xml':
        ensure    => present,
        mode      => '0400',
        owner     => 'root',
        group     => 'root',
        content   => template('profile/ceph/libvirt-secret.xml.erb'),
        show_diff => false,
        require   => Package['ceph-common'],
    }

    # Add the keydata to libvirt, which is referenced by nova-compute in nova.conf
    exec { 'check-virsh-secret':
        command   => '/usr/bin/virsh secret-define --file /etc/ceph/libvirt-secret.xml',
        unless    => "/usr/bin/virsh secret-list | grep -q ${libvirt_rbd_uuid}",
        logoutput => false,
        require   => File['/etc/ceph/libvirt-secret.xml'],
    }
    exec { 'set-virsh-secret':
        command   => "/usr/bin/virsh secret-set-value --secret ${libvirt_rbd_uuid} --base64 ${keydata}",
        unless    => "/usr/bin/virsh secret-get-value --secret ${libvirt_rbd_uuid} | grep -q ${keydata}",
        logoutput => false,
        require   => Exec['check-virsh-secret'],
    }
}