Puppet Class: role::labs::nfs::secondary

Defined in:
modules/role/manifests/labs/nfs/secondary.pp

Overview

Parameters:

  • observer_pass (Any) (defaults to: hiera('profile::openstack::main::observer_password'))
  • monitor_iface (Any) (defaults to: 'eth0')
  • data_iface (Any) (defaults to: 'eth1')


1
2
3
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
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
# File 'modules/role/manifests/labs/nfs/secondary.pp', line 1

class role::labs::nfs::secondary(
  $observer_pass = hiera('profile::openstack::main::observer_password'),
  $monitor_iface = 'eth0',
  $data_iface    = 'eth1',
) {

    system::role { 'labs::nfs::secondary':
        description => 'NFS secondary share cluster',
    }

    include ::standard
    require ::profile::openstack::main::clientpackages
    require ::profile::openstack::main::observerenv
    include labstore::fileserver::secondary
    include labstore::backup_keys
    include role::labs::db::maintain_dbusers

    sysctl::parameters { 'cloudstore base':
        values   => {
            # Increase TCP max buffer size
            'net.core.rmem_max' => 67108864,
            'net.core.wmem_max' => 67108864,

            # Increase Linux auto-tuning TCP buffer limits
            # Values represent min, default, & max num. of bytes to use.
            'net.ipv4.tcp_rmem' => [ 4096, 87380, 33554432 ],
            'net.ipv4.tcp_wmem' => [ 4096, 65536, 33554432 ],
        },
        priority => 70,
    }

    class {'::labstore::fileserver::exports':
        observer_pass => $observer_pass,
    }

    # Enable RPS to balance IRQs over CPUs
    interface::rps { 'monitor':
        interface => $monitor_iface,
    }

    interface::manual{ 'data':
        interface => $data_iface,
    }

    if $::hostname == 'labstore1004' {
        # Define DRBD role for this host, should come from hiera
        $drbd_role = 'primary'

        # Do not change the 192 address here
        interface::ip { 'drbd-replication':
            interface => $data_iface,
            address   => '192.168.0.1',
            prefixlen => '30',
            require   => Interface::Manual['data'],
        }
    }

    if $::hostname == 'labstore1005' {
        # Define DRBD role for this host, should come from hiera
        $drbd_role = 'secondary'

        # Do not change the 192 address here
        interface::ip { 'drbd-replication':
            interface => $data_iface,
            address   => '192.168.0.2',
            prefixlen => '30',
            require   => Interface::Manual['data'],
        }
    }

    # TODO: hiera this
    # TODO: use hiera in maintain_dbusers too when this is hiera'd

    # Floating IP assigned to drbd primary(active NFS server). Should come from hiera
    $cluster_ip = '10.64.37.18'

    $subnet_gateway_ip = '10.64.37.1'

    $drbd_resource_config = {
        'test'   => {
            port       => '7790',
            device     => '/dev/drbd1',
            disk       => '/dev/misc/test',
            mount_path => '/srv/test',
        },
        'tools'  => {
            port       => '7791',
            device     => '/dev/drbd4',
            disk       => '/dev/tools/tools-project',
            mount_path => '/srv/tools',
        },
        'misc' => {
            port       => '7792',
            device     => '/dev/drbd3',
            disk       => '/dev/misc/misc-project',
            mount_path => '/srv/misc',
        },
    }

    $drbd_defaults = {
        'drbd_cluster' => {
            'labstore1004' => '192.168.0.1',
            'labstore1005' => '192.168.0.2',
        },
    }

    create_resources(labstore::drbd::resource, $drbd_resource_config, $drbd_defaults)

    Interface::Ip['drbd-replication'] -> Labstore::Drbd::Resource[keys($drbd_resource_config)]

    # state managed manually
    service { 'drbd':
        enable => false,
    }

    # state via nfs-manage
    if $::lsbdistcodename == 'stretch' {
        service { 'nfs-server':
            enable => false,
        }
    } else {
        service { 'nfs-kernel-server':
            enable => false,
        }
    }

    file { '/usr/local/sbin/nfs-manage':
        content => template('role/labs/nfs/nfs-manage.sh.erb'),
        mode    => '0744',
        owner   => 'root',
        group   => 'root',
    }

    include labstore::monitoring::exports
    include labstore::monitoring::ldap
    class { 'labstore::monitoring::interfaces':
        monitor_iface => $monitor_iface,
    }

    class { 'labstore::monitoring::secondary':
        drbd_role     => $drbd_role,
        cluster_iface => $monitor_iface,
        cluster_ip    => $cluster_ip,
    }

    file {'/usr/local/sbin/logcleanup':
        source => 'puppet:///modules/labstore/logcleanup.py',
        mode   => '0744',
        owner  => 'root',
        group  => 'root',
    }

    file {'/etc/logcleanup-config.yaml':
        source => 'puppet:///modules/role/labs/labstore/secondary/logcleanup-config.yaml',
        mode   => '0644',
        owner  => 'root',
        group  => 'root',
    }

    file { '/usr/local/sbin/safe-du':
        source => 'puppet:///modules/labstore/monitor/safe-du.sh',
        mode   => '0744',
        owner  => 'root',
        group  => 'root',
    }

    sudo::user { 'diamond_dir_size_tracker':
        user       => 'diamond',
        privileges => ['ALL = NOPASSWD: /usr/local/sbin/safe-du'],
        require    => File['/usr/local/sbin/safe-du'],
    }

    if($drbd_role == 'primary') {

        class { 'profile::prometheus::node_directory_size':
            directory_size_paths => {
                'misc_home'     => { 'path' => '/exp/project/*/home', 'filter' => '*/tools/*' },
                'misc_project'  => { 'path' => '/exp/project/*/project', 'filter' => '*/tools/*' },
                'tools_home'    => { 'path' => '/exp/project/tools/home/*' },
                'tools_project' => { 'path' => '/exp/project/tools/project/*' },
                'paws'          => { 'path' => '/exp/project/tools/project/paws/userhomes/*' },
            },
        }
    }

    if($drbd_role != 'primary') {
        cron { 'logcleanup':
            ensure      => absent,
            environment => 'MAILTO=labs-admin@lists.wikimedia.org',
            command     => '/usr/local/sbin/logcleanup --config /etc/logcleanup-config.yaml',
            user        => 'root',
            minute      => '0',
            hour        => '14',
            require     => [File['/usr/local/sbin/logcleanup'], File['/etc/logcleanup-config.yaml']],
        }
    }
}