Puppet Class: profile::spicerack

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

Summary

Installs the spicerack library and cookbook entry point and their configuration.

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • tcpircbot_host (String) (defaults to: lookup('tcpircbot_host'))

    Hostname for the IRC bot.

  • tcpircbot_port (Stdlib::Port) (defaults to: lookup('tcpircbot_port'))

    Port to use with the IRC bot.

  • http_proxy (String) (defaults to: lookup('http_proxy'))

    a http_proxy to use for connections

  • netbox_api (Stdlib::HTTPUrl) (defaults to: lookup('netbox_api_url'))

    the url for the netbox api

  • redis_shards (Hash) (defaults to: lookup('redis::shards'))

    A hash of Redis shards, with the top level key `sessions`, containing a hash keyed by data center, and then by shard name, each shard having a host and port key.

  • netbox_token_ro (String) (defaults to: lookup('profile::netbox::ro_token'))

    The readonly token for netbox

  • netbox_token_rw (String) (defaults to: lookup('profile::netbox::rw_token'))

    The read/write token for netbox

  • ganeti_user (String) (defaults to: lookup('profile::ganeti::rapi::ro_user'))

    A Ganeti RAPI user name for Spicerack to use.

  • ganeti_password (String) (defaults to: lookup('profile::ganeti::rapi::ro_password'))

    The password for the above user.

  • ganeti_timeout (Integer) (defaults to: lookup('profile::spicerack::ganeti_rapi_timeout'))

    timeout parameter when talking to ganeti

  • peeringdb_temp_dir (Stdlib::Unixpath) (defaults to: lookup('profile::spicerack::peeringdb_temp_dir'))

    a temp directory to use for peeringdb cache

  • peeringdb_token_ro (String) (defaults to: lookup('profile::spicerack::peeringdb_ro_token'))

    The perringdb readonly token

  • firmware_store_dir (Stdlib::Unixpath) (defaults to: lookup('profile::spicerack::firmware_store_dir'))

    The location to store firmware images



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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'modules/profile/manifests/spicerack.pp', line 19

class profile::spicerack (
    String           $tcpircbot_host     = lookup('tcpircbot_host'),
    Stdlib::Port     $tcpircbot_port     = lookup('tcpircbot_port'),
    String           $http_proxy         = lookup('http_proxy'),
    Stdlib::HTTPUrl  $netbox_api         = lookup('netbox_api_url'),
    Hash             $redis_shards       = lookup('redis::shards'),
    String           $netbox_token_ro    = lookup('profile::netbox::ro_token'),
    String           $netbox_token_rw    = lookup('profile::netbox::rw_token'),
    String           $ganeti_user        = lookup('profile::ganeti::rapi::ro_user'),
    String           $ganeti_password    = lookup('profile::ganeti::rapi::ro_password'),
    Integer          $ganeti_timeout     = lookup('profile::spicerack::ganeti_rapi_timeout'),
    Stdlib::Unixpath $peeringdb_temp_dir = lookup('profile::spicerack::peeringdb_temp_dir'),
    String           $peeringdb_token_ro = lookup('profile::spicerack::peeringdb_ro_token'),
    Stdlib::Unixpath $firmware_store_dir = lookup('profile::spicerack::firmware_store_dir'),
) {
    # Ensure pre-requisite profiles are included
    require profile::conftool::client
    require profile::cumin::master
    require profile::ipmi::mgmt
    require profile::access_new_install

    class { 'service::deploy::common': }
    include passwords::redis

    # Packages required by spicerack cookbooks
    ensure_packages([
        'python3-dateutil', 'python3-prettytable', 'python3-requests', 'python3-packaging', 'spicerack',
    ])

    $cookbooks_dir = '/srv/deployment/spicerack'

    # Install the cookbooks
    git::clone { 'operations/cookbooks':
        ensure    => 'latest',
        directory => $cookbooks_dir,
    }

    # this directory is created by the debian package however we still manage it to force
    # an auto require on all files under it this directory
    file { '/etc/spicerack':
        ensure  => directory,
        owner   => 'root',
        group   => 'ops',
        mode    => '0550',
        require => Package['spicerack'],
    }

    file { '/etc/spicerack/config.yaml':
        ensure  => file,
        owner   => 'root',
        group   => 'ops',
        mode    => '0440',
        content => template('profile/spicerack/config.yaml.erb'),
    }

    ### SPICERACK MODULES CONFIGURATION FILES

    # Redis-specific configuration
    $redis_sessions_data = {
        'password' => $passwords::redis::main_password,
        'shards' => $redis_shards['sessions'],
    }

    # Ganeti RAPI configuration
    $ganeti_auth_data = {
        'username' => $ganeti_user,
        'password' => $ganeti_password,
        'timeout'  => $ganeti_timeout,
    }

    # Netbox backend configuration
    $netbox_config_data = {
        'api_url'   => $netbox_api,
        'api_token_ro' => $netbox_token_ro,
        'api_token_rw' => $netbox_token_rw,
    }

    # PeeringDB backend configuration
    $peeringdb_config_data = {
        'api_token_ro' => $peeringdb_token_ro,
        'cachedir'     => $peeringdb_temp_dir,
    }

    # Kafka cluster brokers configuration
    $kafka_config_data = {
        'main'   => {
            'eqiad' => kafka_config('main', 'eqiad'),
            'codfw' => kafka_config('main', 'codfw'),
        },
        'jumbo' => {
            'eqiad' => kafka_config('jumbo', 'eqiad'),
        },
        'logging' => {
            'eqiad' => kafka_config('logging', 'eqiad'),
            'codfw' => kafka_config('logging', 'codfw'),
        },
    }

    # Elasticsearch cluster configuration
    $elasticsearch_config_data = {
    'search'                                          => {
        'search_eqiad' => {
          'production-search-eqiad' => 'https://search.svc.eqiad.wmnet:9243',
          'production-search-omega-eqiad' => 'https://search.svc.eqiad.wmnet:9443',
          'production-search-psi-eqiad' => 'https://search.svc.eqiad.wmnet:9643',
        },
        'search_codfw' => {
          'production-search-codfw' => 'https://search.svc.codfw.wmnet:9243',
          'production-search-omega-codfw' => 'https://search.svc.codfw.wmnet:9443',
          'production-search-psi-codfw' => 'https://search.svc.codfw.wmnet:9643',
        },
        'relforge' => {
          'relforge-eqiad' => 'https://relforge1004.eqiad.wmnet:9243',
          'relforge-eqiad-small-alpha' => 'https://relforge1004.eqiad.wmnet:9443',
        },
        'cloudelastic' => {
          'cloudelastic-chi-https' => 'https://cloudelastic.wikimedia.org:9243',
          'cloudelastic-omega-https' => 'https://cloudelastic.wikimedia.org:9443',
          'cloudelastic-psi-https' => 'https://cloudelastic.wikimedia.org:9643',
        },
      },
    'logging'                                         => {
          'logging-eqiad' => 'http://logstash1010.eqiad.wmnet:9200',
          'logging-codfw' => 'http://logstash2001.codfw.wmnet:9200',
      },
    }

    # Install all configuration files
    # Semicolon needed for https://tickets.puppetlabs.com/browse/PUP-10782
    ; {
        'elasticsearch' => { 'config.yaml' => $elasticsearch_config_data },
        'ganeti' => { 'config.yaml' => $ganeti_auth_data },
        'kafka' => { 'config.yaml' => $kafka_config_data },
        'netbox' => { 'config.yaml' => $netbox_config_data },
        'peeringdb' => { 'config.yaml' => $peeringdb_config_data },
        'redis_cluster' => { 'sessions.yaml' => $redis_sessions_data },
        'service' => { 'service.yaml' => wmflib::service::fetch() },
    }.each | $dir, $file_data | {
        file { "/etc/spicerack/${dir}":
            ensure => directory,
            owner  => 'root',
            group  => 'ops',
            mode   => '0550',
        }
        $file_data.each | $filename, $content | {
            file { "/etc/spicerack/${dir}/${filename}":
                ensure  => file,
                owner   => 'root',
                group   => 'ops',
                mode    => '0440',
                content => to_yaml($content),
            }
        }
    }

    ### COOKBOOKS CONFIGURATION FILES

    file { '/etc/spicerack/cookbooks':
        ensure => directory,
        owner  => 'root',
        group  => 'ops',
        mode   => '0550',
    }

    wmflib::dir::mkdir_p($firmware_store_dir, {
        group => 'datacenter-ops',
        mode  => '2775',
    })
    file { '/etc/spicerack/cookbooks/sre.hardware.upgrade-firmware.yaml':
        ensure  => file,
        content => {
            'firmware_store' => $firmware_store_dir,
        }.to_yaml,
    }

    file { '/etc/spicerack/cookbooks/sre.network.cf.yaml':
        ensure  => file,
        owner   => 'root',
        group   => 'ops',
        mode    => '0440',
        content => secret('spicerack/cookbooks/sre.network.cf.yaml'),
    }

    # Configuration file for switching services between datacenters
    # For each discovery record for active-active services, extract the
    # actual dns from monitoring if available.
    $discovery_records = wmflib::service::fetch().filter |$label, $record| {
        $record['discovery'] != undef
    }

    file { '/etc/spicerack/cookbooks/sre.switchdc.services.yaml':
        ensure  => file,
        owner   => 'root',
        group   => 'ops',
        mode    => '0440',
        content => template('profile/spicerack/sre.switchdc.services.yaml.erb'),
    }
}