Puppet Class: profile::wmcs::nfs::secondary

Defined in:
modules/profile/manifests/wmcs/nfs/secondary.pp

Overview

Parameters:

  • observer_pass (String) (defaults to: lookup('profile::openstack::eqiad1::observer_password'))
  • data_iface (String) (defaults to: lookup('profile::wmcs::nfs::secondary::data_iface', {'default_value' => 'eno3'}))
  • drbd_resource_config (Hash[String, Hash[String, Variant[Integer,String]]]) (defaults to: lookup('profile::wmcs::nfs::secondary::drbd_resource_config'))
  • drbd_cluster (Hash[String, Stdlib::IP::Address::V4]) (defaults to: lookup('profile::wmcs::nfs::secondary::drbd_cluster'))
  • cluster_ip (Stdlib::IP::Address) (defaults to: lookup('profile::wmcs::nfs::secondary::cluster_ip'))
  • cluster_ip_netmask (Integer) (defaults to: lookup('profile::wcms::nfs::secondary::cluster_ip_netmask'))
  • subnet_gateway_ip (Stdlib::IP::Address) (defaults to: lookup('profile::wmcs::nfs::secondary::subnet_gateway_ip'))
  • standby_server (Stdlib::Fqdn) (defaults to: lookup('profile::wmcs::nfs::secondary::standby'))
  • secondary_servers (Array[Stdlib::Host]) (defaults to: lookup('secondary_nfs_servers'))


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
# File 'modules/profile/manifests/wmcs/nfs/secondary.pp', line 1

class profile::wmcs::nfs::secondary(
    String $observer_pass = lookup('profile::openstack::eqiad1::observer_password'),
    String $data_iface    = lookup('profile::wmcs::nfs::secondary::data_iface', {'default_value' => 'eno3'}),
    Hash[String, Hash[String, Variant[Integer,String]]] $drbd_resource_config = lookup('profile::wmcs::nfs::secondary::drbd_resource_config'),
    Hash[String, Stdlib::IP::Address::V4] $drbd_cluster = lookup('profile::wmcs::nfs::secondary::drbd_cluster'),
    Stdlib::IP::Address $cluster_ip = lookup('profile::wmcs::nfs::secondary::cluster_ip'),
    Integer $cluster_ip_netmask     = lookup('profile::wcms::nfs::secondary::cluster_ip_netmask'),
    Stdlib::IP::Address $subnet_gateway_ip = lookup('profile::wmcs::nfs::secondary::subnet_gateway_ip'),
    Stdlib::Fqdn $standby_server     = lookup('profile::wmcs::nfs::secondary::standby'),
    Array[Stdlib::Host] $secondary_servers = lookup('secondary_nfs_servers'),
) {
    require ::profile::openstack::eqiad1::clientpackages
    require ::profile::openstack::eqiad1::observerenv

    $monitor_iface = $facts['networking']['primary']
    class {'::labstore':
        nfsd_threads => 192,
    }

    ensure_packages([
        'python3-paramiko',
        'python3-pymysql',
        'python3-dateutil',
        'arping',
    ])

    # Enable RPS to balance IRQs over CPUs
    # This breaks the puppet compiler, so re-enable after testing compiles
    # interface::rps { 'monitor':
    #     interface => $monitor_iface,
    # }
    $drbd_expected_role = $facts['fqdn'] ? {
        $standby_server => 'secondary',
        default         => 'primary',
    }

    # Determine the actual role from a custom fact.
    if has_key($facts, 'drbd_role') {
        if $facts['drbd_role'].values().unique().length() > 1 {
            $drbd_actual_role = 'inconsistent'
        } else {
            $drbd_actual_role = $facts['drbd_role'].values().unique()[0]
        }
    } else {
        $drbd_actual_role = undef
    }

    $drbd_ip_address = $drbd_cluster[$facts['hostname']]

    # Make sure the mountpoints are there
    file{'/srv/test':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0777',
    }

    file{'/srv/misc':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
    }

    file{'/srv/scratch':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '1777',
    }

    $drbd_defaults = {
        'drbd_cluster' => $drbd_cluster
    }

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

    interface::ip { 'drbd-replication':
        interface => $data_iface,
        address   => $drbd_ip_address,
        prefixlen => '30',
        require   => Interface::Manual['data'],
    }

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

    Interface::Ip['drbd-replication'] -> Labstore::Drbd::Resource[keys($drbd_resource_config)]
    $cluster_ips_ferm = join($drbd_cluster.values(), ' ')
    $drbd_resource_config.each |String $volume, Hash $volume_config| {
        ferm::service { "drbd-${volume}":
            proto  => 'tcp',
            port   => $volume_config['port'],
            srange => "(${cluster_ips_ferm})",
        }
    }

    # state managed manually
    service { 'drbd':
        enable => false,
    }
    service { 'nfs-server':
        enable => false,
    }
    $nfs_start_command = 'systemctl start nfs-server'
    $nfs_stop_command = 'systemctl stop nfs-server'

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

    class {'labstore::monitoring::exports':
        drbd_role => $drbd_actual_role,
    }
    class {'labstore::monitoring::volumes':
        server_vols => [
            '/srv/maps',
            '/srv/scratch'
        ],
        drbd_role   => $drbd_actual_role,
    }

    class {'labstore::fileserver::exports':
        server_vols   => ['maps'],
    }

    class {'labstore::monitoring::ldap': }
    class { 'labstore::monitoring::interfaces':
        monitor_iface       => 'eno1',
        int_throughput_warn => 937500000,  # 7500Mbps
        int_throughput_crit => 1062500000, # 8500Mbps
    }

    $secondary_servers_ferm = join($secondary_servers, ' ')
    ferm::service { 'labstore_nfs_portmapper_udp_monitor':
        proto  => 'udp',
        port   => '111',
        srange => "(@resolve((${secondary_servers_ferm})) @resolve((${secondary_servers_ferm}), AAAA))",
    }
    ferm::service { 'labstore_nfs_monitor':
        proto  => 'tcp',
        port   => '2049',
        srange => "(@resolve((${secondary_servers_ferm})) @resolve((${secondary_servers_ferm}), AAAA))",
    }
    ferm::service { 'labstore_nfs_cluster_rpc_mountd':
        proto  => 'tcp',
        port   => '38466',
        srange => "(@resolve((${secondary_servers_ferm})) @resolve((${secondary_servers_ferm}), AAAA))",
    }

    nrpe::monitor_service { 'check_nfs_status':
        description   => 'NFS port is open on cluster IP',
        nrpe_command  => "/usr/lib/nagios/plugins/check_tcp -H ${cluster_ip} -p 2049 --timeout=2",
        contact_group => 'wmcs-team',
        notes_url     => 'https://wikitech.wikimedia.org/wiki/Portal:Data_Services/Admin/Labstore',
    }
}