Puppet Class: cloud::compute::hypervisor

Defined in:
manifests/compute/hypervisor.pp

Overview

Parameters:

  • server_proxyclient_address (Any) (defaults to: $os_params::internal_netif_ip)
  • libvirt_type (Any) (defaults to: $os_params::libvirt_type)
  • ks_nova_public_proto (Any) (defaults to: $os_params::ks_nova_public_proto)
  • ks_nova_public_host (Any) (defaults to: $os_params::ks_nova_public_host)
  • nova_ssh_private_key (Any) (defaults to: $os_params::nova_ssh_private_key)
  • nova_ssh_public_key (Any) (defaults to: $os_params::nova_ssh_public_key)
  • spice_port (Any) (defaults to: $os_params::spice_port)
  • cinder_rbd_user (Any) (defaults to: $os_params::cinder_rbd_user)
  • nova_rbd_pool (Any) (defaults to: $os_params::nova_rbd_pool)
  • nova_rbd_secret_uuid (Any) (defaults to: $os_params::ceph_fsid)
  • has_ceph (Any) (defaults to: false)


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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'manifests/compute/hypervisor.pp', line 29

class cloud::compute::hypervisor(
  $server_proxyclient_address = $os_params::internal_netif_ip,
  $libvirt_type               = $os_params::libvirt_type,
  $ks_nova_public_proto       = $os_params::ks_nova_public_proto,
  $ks_nova_public_host        = $os_params::ks_nova_public_host,
  $nova_ssh_private_key       = $os_params::nova_ssh_private_key,
  $nova_ssh_public_key        = $os_params::nova_ssh_public_key,
  $spice_port                 = $os_params::spice_port,
  $cinder_rbd_user            = $os_params::cinder_rbd_user,
  $nova_rbd_pool              = $os_params::nova_rbd_pool,
  $nova_rbd_secret_uuid       = $os_params::ceph_fsid,
  $has_ceph                   = false
) {

  include 'cloud::compute'
  include 'cloud::telemetry'
  include 'cloud::network'

  file{ '/var/lib/nova/.ssh':
    ensure  => directory,
    mode    => '0700',
    owner   => 'nova',
    group   => 'nova',
    require => Class['nova']
  } ->
  file{ '/var/lib/nova/.ssh/id_rsa':
    ensure  => present,
    mode    => '0600',
    owner   => 'nova',
    group   => 'nova',
    content => $nova_ssh_private_key
  } ->
  file{ '/var/lib/nova/.ssh/authorized_keys':
    ensure  => present,
    mode    => '0600',
    owner   => 'nova',
    group   => 'nova',
    content => $nova_ssh_public_key
  } ->
  file{ '/var/lib/nova/.ssh/config':
    ensure  => present,
    mode    => '0600',
    owner   => 'nova',
    group   => 'nova',
    content => "
Host *
    StrictHostKeyChecking no
"
  }

  class { 'nova::compute':
    enabled         => true,
    vnc_enabled     => false,
    #TODO(EmilienM) Bug #1259545 currently WIP:
    virtio_nic      => false,
    neutron_enabled => true
  }

  class { 'nova::compute::spice':
    server_listen              => '0.0.0.0',
    server_proxyclient_address => $server_proxyclient_address,
    proxy_host                 => $ks_nova_public_host,
    proxy_protocol             => $ks_nova_public_proto,
    proxy_port                 => $spice_port

  }

  if $::operatingsystem == 'RedHat' {
    file { '/etc/libvirt/qemu.conf':
      ensure => file,
      source => 'puppet:///modules/cloud/qemu/qemu.conf',
      owner  => root,
      group  => root,
      mode   => '0644',
      notify => Service['libvirtd']
    }
  }

  if $::operatingsystem == 'Ubuntu' {
    service { 'dbus':
      ensure => running,
      enable => true,
      before => Class['nova::compute::libvirt'],
    }
  }

  Service<| title == 'dbus' |> { enable => true }

  Service<| title == 'libvirt-bin' |> { enable => true }

  class { 'nova::compute::neutron': }

  if $has_ceph {

    $libvirt_disk_cachemodes_real = ['network=writeback']
    include 'cloud::storage::rbd'

    # TODO(EmilienM) Temporary, while https://review.openstack.org/#/c/72440 got merged
    nova_config {
      'DEFAULT/libvirt_images_type':          value => 'rbd';
      'DEFAULT/libvirt_images_rbd_pool':      value => $nova_rbd_pool;
      'DEFAULT/libvirt_images_rbd_ceph_conf': value => '/etc/ceph/ceph.conf';
      'DEFAULT/rbd_user':                     value => $cinder_rbd_user;
      'DEFAULT/rbd_secret_uuid':              value => $nova_rbd_secret_uuid;
    }

    File <<| tag == 'ceph_compute_secret_file' |>>
    Exec <<| tag == 'get_or_set_virsh_secret' |>>
    Exec <<| tag == 'set_secret_value_virsh' |>>

    # Configure Ceph keyring
    Ceph::Key <<| title == $cinder_rbd_user |>>

    # If Cinder & Nova reside on the same node, we need a group
    # where nova & cinder users have read permissions.
    ensure_resource('group', 'cephkeyring', {
      ensure => 'present'
    })

    ensure_resource ('exec','add-nova-to-group', {
      'command' => 'usermod -a -G cephkeyring nova',
      'unless'  => 'groups nova | grep cephkeyring'
    })

    ensure_resource('file', "/etc/ceph/ceph.client.${cinder_rbd_user}.keyring", {
      owner   => 'root',
      group   => 'cephkeyring',
      mode    => '0440',
      require => Ceph::Key[$cinder_rbd_user],
    })

    Concat::Fragment <<| title == 'ceph-client-os' |>>
  } else {
    $libvirt_disk_cachemodes_real = []
  }

  class { 'nova::compute::libvirt':
    libvirt_type            => $libvirt_type,
    # Needed to support migration but we still use Spice:
    vncserver_listen        => '0.0.0.0',
    migration_support       => true,
    libvirt_disk_cachemodes => $libvirt_disk_cachemodes_real
  }

  # Extra config for nova-compute
  nova_config {
    'DEFAULT/libvirt_inject_key':        value => false;
    'DEFAULT/libvirt_inject_partition':  value => '-2';
    'DEFAULT/live_migration_flag':       value => 'VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST';
  }

  class { 'ceilometer::agent::compute': }

}