Puppet Class: profile::spicerack

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

Overview

Parameters:

  • tcpircbot_host (String) (defaults to: lookup('tcpircbot_host'))
  • tcpircbot_port (Stdlib::Port) (defaults to: lookup('tcpircbot_port'))
  • redis_shards (Hash) (defaults to: lookup('redis::shards'))
  • ganeti_user (String) (defaults to: lookup('profile::ganeti::rapi::ro_user'))
  • ganeti_password (String) (defaults to: lookup('profile::ganeti::rapi::ro_password'))
  • ganeti_timeout (Integer) (defaults to: lookup('profile::spicerack::ganeti_rapi_timeout', {'default_value' => 30}))
  • netbox_api (Stdlib::HTTPUrl) (defaults to: lookup('netbox::api_url'))
  • netbox_token_ro (String) (defaults to: lookup('profile::netbox::tokens::read_only'))
  • netbox_token_rw (String) (defaults to: lookup('profile::netbox::tokens::read_write'))
  • http_proxy (String) (defaults to: lookup('http_proxy'))


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
# File 'modules/profile/manifests/spicerack.pp', line 25

class profile::spicerack(
    String $tcpircbot_host = lookup('tcpircbot_host'),
    Stdlib::Port $tcpircbot_port = lookup('tcpircbot_port'),
    Hash $redis_shards = lookup('redis::shards'),
    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', {'default_value' => 30}),
    Stdlib::HTTPUrl $netbox_api = lookup('netbox::api_url'),
    String $netbox_token_ro = lookup('profile::netbox::tokens::read_only'),
    String $netbox_token_rw = lookup('profile::netbox::tokens::read_write'),
    String $http_proxy = lookup('http_proxy'),
) {
    # Ensure pre-requisite profiles are included
    require profile::conftool::client
    require profile::cumin::master
    require profile::ipmi::mgmt
    require profile::access_new_install

    include service::deploy::common
    include passwords::redis

    # Packages required by spicerack cookbooks
    ensure_packages(['python3-dateutil', 'python3-requests', '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  => present,
        owner   => 'root',
        group   => 'ops',
        mode    => '0440',
        content => template('profile/spicerack/config.yaml.erb'),
    }

    # Install the Redis-specific configuration
    file { '/etc/spicerack/redis_cluster':
        ensure => directory,
        owner  => 'root',
        group  => 'ops',
        mode   => '0550',
    }

    $redis_sessions_data = {
        'password' => $passwords::redis::main_password,
        'shards' => $redis_shards['sessions'],
    }
    file { '/etc/spicerack/redis_cluster/sessions.yaml':
        ensure  => present,
        owner   => 'root',
        group   => 'ops',
        mode    => '0440',
        content => ordered_yaml($redis_sessions_data),
    }

    # Install Ganeti RAPI configuration
    file { '/etc/spicerack/ganeti':
        ensure => directory,
        owner  => 'root',
        group  => 'ops',
        mode   => '0550',
    }
    $ganeti_auth_data = {
        'username' => $ganeti_user,
        'password' => $ganeti_password,
        'timeout'  => $ganeti_timeout,
    }
    file { '/etc/spicerack/ganeti/config.yaml':
        ensure  => present,
        owner   => 'root',
        group   => 'ops',
        mode    => '0440',
        content => ordered_yaml($ganeti_auth_data),
    }
    # Install Netbox backend configuration
    file { '/etc/spicerack/netbox':
        ensure => directory,
        owner  => 'root',
        group  => 'ops',
        mode   => '0550',
    }
    $netbox_config_data = {
        'api_url'   => $netbox_api,
        'api_token_ro' => $netbox_token_ro,
        'api_token_rw' => $netbox_token_rw,
    }
    file { '/etc/spicerack/netbox/config.yaml':
        ensure  => present,
        owner   => 'root',
        group   => 'ops',
        mode    => '0440',
        content => ordered_yaml($netbox_config_data),
    }

    # Install Kafka cluster brokers configuration
    file { '/etc/spicerack/kafka':
        ensure => directory,
        owner  => 'root',
        group  => 'ops',
        mode   => '0550',
    }

    $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'),
        }
    }

    file { '/etc/spicerack/kafka/config.yaml':
        ensure  => present,
        owner   => 'root',
        group   => 'ops',
        mode    => '0440',
        content => ordered_yaml($kafka_config_data),
    }

    file { '/etc/spicerack/cookbooks':
        ensure => directory,
        owner  => 'root',
        group  => 'ops',
        mode   => '0550',
    }
    file { '/etc/spicerack/cookbooks/sre.network.cf.yaml':
        ensure  => present,
        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  => present,
        owner   => 'root',
        group   => 'ops',
        mode    => '0440',
        content => template('profile/spicerack/sre.switchdc.services.yaml.erb')
    }
}