Puppet Class: openstack::nova::compute::service

Defined in:
modules/openstack/manifests/nova/compute/service.pp

Overview

The 'nova compute' service does the actual VM management

within nova.

wiki.openstack.org/wiki/Nova

Parameters:

  • all_cloudvirts (Array[Stdlib::Fqdn])
  • certpath (Stdlib::Unixpath)
  • version (String)
  • libvirt_cpu_model (String)
  • enable_nova_rbd (Optional[Boolean]) (defaults to: false)
  • ceph_rbd_pool (Optional[String]) (defaults to: undef)
  • ceph_rbd_client_name (Optional[String]) (defaults to: undef)
  • libvirt_rbd_uuid (Optional[String]) (defaults to: undef)
  • compute_id (Optional[String[1]]) (defaults to: undef)


4
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
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
# File 'modules/openstack/manifests/nova/compute/service.pp', line 4

class openstack::nova::compute::service(
    Array[Stdlib::Fqdn] $all_cloudvirts,
    Stdlib::Unixpath    $certpath,
    String              $version,
    String              $libvirt_cpu_model,
    Optional[Boolean]   $enable_nova_rbd      = false,
    Optional[String]    $ceph_rbd_pool        = undef,
    Optional[String]    $ceph_rbd_client_name = undef,
    Optional[String]    $libvirt_rbd_uuid     = undef,
    Optional[String[1]] $compute_id           = undef,
    ){

    $libvirt_unix_sock_group = 'libvirt'

    class { "openstack::nova::compute::service::${version}::${::lsbdistcodename}":
    }

    include openstack::nova::compute::kmod

    # use exec to set the shell to not shadow the manage
    # the user for the package which causes Puppet
    # to see the user as a dependency anywhere the
    # nova user is used to ensure good permission
    exec {'set_shell_for_nova':
        command   => '/usr/sbin/usermod -c "shell set for online operations" -s /bin/bash nova',
        unless    => '/bin/grep "nova:" /etc/passwd | /bin/grep ":\/bin\/bash"',
        logoutput => true,
        require   => Package['nova-compute'],
    }

    ssh::userkey { 'nova':
        content => secret('ssh/nova/nova.pub'),
        require => Exec['set_shell_for_nova'],
    }

    file { '/var/lib/nova/.ssh':
        ensure  => 'directory',
        owner   => 'nova',
        group   => 'nova',
        mode    => '0700',
        require => Package['nova-compute'],
    }

    file { '/var/lib/nova/.ssh/id_rsa':
        owner     => 'nova',
        group     => 'nova',
        mode      => '0600',
        content   => secret('ssh/nova/nova.key'),
        require   => File['/var/lib/nova/.ssh'],
        show_diff => false,
    }

    file { '/var/lib/nova/.ssh/id_rsa.pub':
        owner   => 'nova',
        group   => 'nova',
        mode    => '0600',
        content => secret('ssh/nova/nova.pub'),
        require => File['/var/lib/nova/.ssh'],
    }

    service { 'nova-compute':
        ensure    => 'running',
        subscribe => [
                      File['/etc/nova/nova.conf'],
                      File['/etc/nova/nova-compute.conf'],
            ],
        require   => [Package['nova-compute'], File['/etc/ceph/ceph.conf']],
    }

    # Guest management on host startup/reboot
    file { '/etc/default/libvirt-guests':
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
        source => 'puppet:///modules/openstack/nova/libvirt/libvirt-guests',
    }

    service { 'libvirt-guests':
        ensure => 'running',
        enable => true,
    }

    file { '/etc/libvirt/libvirtd.conf':
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template("openstack/${version}/nova/compute/libvirtd.conf.erb"),
        notify  => Service['libvirtd'],
        require => [Package['nova-compute'], File['/var/lib/nova/cacert.pem']]
    }

    file { '/etc/default/libvirtd':
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template("openstack/${version}/nova/compute/libvirt.default.erb"),
        notify  => Service['libvirtd'],
        require => Package['nova-compute'],
    }

    file { '/etc/nova/nova-compute.conf':
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template("openstack/${version}/nova/compute/nova-compute.conf.erb"),
        notify  => Service['nova-compute'],
        require => Package['nova-compute'],
    }

    file { '/etc/modprobe.d/kvm_intel.conf':
        ensure => present,
        owner  => 'root',
        group  => 'root',
        mode   => '0644',
        source => 'puppet:///modules/openstack/nova/kvm_intel.conf',
    }

    profile::auto_restarts::service { 'virtlogd': }

    # see https://phabricator.wikimedia.org/T357631
    # and also https://docs.openstack.org/nova/latest/admin/compute-node-identification.html
    if $compute_id {
        # special case in which the cloudvirt already has a known compute_id that needs to be preserved
        # this will be the case for every cloudvirt that is reimaged but already had a random uuid generated by nova
        $compute_id_content = $compute_id
    } else {
        # general case: we don't care what the uuid is, just generate one, based on the hostname
        # this will be the case for every new cloudvirt being set up
        $compute_id_content = fqdn_uuid($::fqdn)
    }

    file { '/etc/nova/compute_id':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
        content => "${compute_id_content}\n"
    }
}