Puppet Class: profile::ganeti

Defined in:
modules/profile/manifests/ganeti.pp

Overview

Parameters:

  • nodes (Array[Stdlib::Fqdn]) (defaults to: lookup('profile::ganeti::nodes'))
  • rapi_nodes (Array[Stdlib::Fqdn]) (defaults to: lookup('profile::ganeti::rapi_nodes'))
  • rapi_ro_user (Optional[String]) (defaults to: lookup('profile::ganeti::rapi::ro_user', { default_value => undef }))
  • rapi_ro_password (Optional[String]) (defaults to: lookup('profile::ganeti::rapi::ro_password', { default_value => undef }))


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
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 'modules/profile/manifests/ganeti.pp', line 28

class profile::ganeti (
    Array[Stdlib::Fqdn] $nodes         = lookup('profile::ganeti::nodes'),
    Array[Stdlib::Fqdn] $rapi_nodes    = lookup('profile::ganeti::rapi_nodes'),
    Optional[String] $rapi_ro_user     = lookup('profile::ganeti::rapi::ro_user',
                                                { default_value => undef }),
    Optional[String] $rapi_ro_password = lookup('profile::ganeti::rapi::ro_password',
                                                { default_value => undef }),
) {

    class { '::ganeti': }

    # Ganeti needs intracluster SSH root access
    # DSS+RSA keys in here, but note that DSS is deprecated
    ssh::userkey { 'root-ganeti':
        ensure => present,
        user   => 'root',
        skey   => 'ganeti',
        source => 'puppet:///modules/profile/ganeti/ganeti.pub',
    }

    # The RSA private key
    file { '/root/.ssh/id_rsa':
        ensure    => present,
        owner     => 'root',
        group     => 'root',
        mode      => '0400',
        content   => secret('ganeti/id_rsa'),
        show_diff => false,
    }
    # This is here for completeness
    file { '/root/.ssh/id_rsa.pub':
        ensure => present,
        owner  => 'root',
        group  => 'root',
        mode   => '0400',
        source => 'puppet:///modules/profile/ganeti/id_rsa.pub',
    }

    motd::script { 'ganeti-master-motd':
        ensure => present,
        source => 'puppet:///modules/profile/ganeti/motd',
    }

    if defined('$rapi_ro_user') and defined('$rapi_ro_password') {
        # Authentication for RAPI (for now just a single read-only user)
        $ro_password_hash = md5("${rapi_ro_user}:Ganeti Remote API:${rapi_ro_password}")
        $real_content = "${rapi_ro_user} {HA1}${ro_password_hash} read\n"
    } else {
        # Provide a blank authentication file for the RAPI server (no users will be defined, thus denying all)
        $real_content = ''
    }
    file { '/var/lib/ganeti/rapi/users':
        ensure  => present,
        owner   => 'gnt-rapi',
        group   => 'gnt-masterd',
        mode    => '0640',
        content => $real_content,
        require => Class['ganeti'],
    }

    # Firewalling
    #

    $ganeti_ferm_nodes = join($nodes, ' ')
    $rapi_access = join(concat($nodes, $rapi_nodes), ' ')

    # Allow SSH between ganeti cluster members
    ferm::service { 'ganeti_ssh_cluster':
        proto  => 'tcp',
        port   => 'ssh',
        srange => "@resolve((${ganeti_ferm_nodes}))",
    }

    # RAPI is the API of ganeti
    ferm::service { 'ganeti_rapi_cluster':
        proto  => 'tcp',
        port   => 5080,
        srange => "@resolve((${rapi_access}))",
    }

    # Ganeti noded is responsible for all cluster/node actions
    ferm::service { 'ganeti_noded_cluster':
        proto  => 'tcp',
        port   => 1811,
        srange => "@resolve((${ganeti_ferm_nodes}))",
    }

    # Ganeti confd provides a HA and fast way to query cluster configuration
    ferm::service { 'ganeti_confd_cluster':
        proto  => 'udp',
        port   => 1814,
        srange => "@resolve((${ganeti_ferm_nodes}))",
    }

    # Ganeti mond is the monitoring daemon. Data is available via port 1815
    ferm::service { 'ganeti_mond_cluster':
        proto  => 'tcp',
        port   => 1815,
        srange => "@resolve((${ganeti_ferm_nodes}))",
    }

    # DRBD is used for HA of disk images. Port range for ganeti is
    # 11000-14999
    ferm::service { 'ganeti_drbd':
        proto  => 'tcp',
        port   => '11000:14999',
        srange => "@resolve((${ganeti_ferm_nodes}))",
    }

    # Migration is done over TCP port
    ferm::service { 'ganeti_migration':
        proto  => 'tcp',
        port   => 8102,
        srange => "@resolve((${ganeti_ferm_nodes}))",
    }

    # If ganeti_cluster fact is not defined, the node has not been added to a
    # cluster yet, so don't monitor
    if $facts['ganeti_cluster'] {

        # Monitoring
        nrpe::monitor_service{ 'ganeti-noded':
            description  => 'ganeti-noded running',
            nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 1:2 -c 1:2 -u root -C ganeti-noded',
            notes_url    => 'https://wikitech.wikimedia.org/wiki/Ganeti',
        }

        nrpe::monitor_service{ 'ganeti-confd':
            description  => 'ganeti-confd running',
            nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 1:1 -c 1:1 -u gnt-confd -C ganeti-confd',
            notes_url    => 'https://wikitech.wikimedia.org/wiki/Ganeti',
        }

        nrpe::monitor_service{ 'ganeti-mond':
            description  => 'ganeti-mond running',
            nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 1:1 -c 1:1 -u root -C ganeti-mond',
            notes_url    => 'https://wikitech.wikimedia.org/wiki/Ganeti',
        }


        if $facts['ganeti_master'] == $facts['fqdn'] {
            nrpe::monitor_service { "https-gnt-rapi-${::site}":
                description  => "HTTPS Ganeti RAPI ${::site}",
                nrpe_command => "/usr/lib/nagios/plugins/check_http -H ${facts['ganeti_cluster']} -p 5080 -S -e 401",
                notes_url    => 'https://www.mediawiki.org/wiki/Ganeti#RAPI_daemon',
            }

            nrpe::monitor_service{ 'ganeti-wconfd':
                description  => 'ganeti-wconfd running',
                nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 1:1 -c 1:1 -u gnt-masterd -C ganeti-wconfd',
                notes_url    => 'https://wikitech.wikimedia.org/wiki/Ganeti',
            }
        }
    }
}