Puppet Class: profile::wmcs::nfsclient

Defined in:
modules/profile/manifests/wmcs/nfsclient.pp

Overview

Parameters:

  • mode (String) (defaults to: lookup('profile::wmcs::nfsclient::mode', {'default_value' => 'hard'}))
  • home_mode (String) (defaults to: lookup('profile::wmcs::nfsclient::home_mode', {'default_value' => 'hard'}))
  • lookupcache (String) (defaults to: lookup('profile::wmcs::nfsclient::lookupcache', {'default_value' => 'all'}))
  • nfs_version (String) (defaults to: lookup('profile::wmcs::nfsclient::nfs_version', {'default_value' => '4'}))
  • dumps_servers (Array[Stdlib::Host]) (defaults to: hiera('dumps_dist_nfs_servers'))
  • dumps_active_server (Stdlib::Host) (defaults to: hiera('dumps_dist_active_vps'))
  • secondary_servers (Array[Stdlib::Host]) (defaults to: lookup('secondary_nfs_servers', {'default_value' => []}))
  • scratch_active_server (Stdlib::Host) (defaults to: lookup('scratch_active_server'))
  • maps_active_server (Stdlib::Host) (defaults to: lookup('scratch_active_server'))


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
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'modules/profile/manifests/wmcs/nfsclient.pp', line 1

class profile::wmcs::nfsclient(
    # Be careful with this setting. Switching to soft mount on a high-churn mount
    # may cause data corruption whenever there is a network or storage issue.
    String $mode = lookup('profile::wmcs::nfsclient::mode', {'default_value' => 'hard'}),
    # This is experimental and should be opt-in. /home on a busy server should be a hard mount.
    String $home_mode = lookup('profile::wmcs::nfsclient::home_mode', {'default_value' => 'hard'}),
    String $lookupcache = lookup('profile::wmcs::nfsclient::lookupcache', {'default_value' => 'all'}),
    String $nfs_version = lookup('profile::wmcs::nfsclient::nfs_version', {'default_value' => '4'}),
    Array[Stdlib::Host] $dumps_servers = hiera('dumps_dist_nfs_servers'),
    Stdlib::Host $dumps_active_server = hiera('dumps_dist_active_vps'),
    Array[Stdlib::Host] $secondary_servers = lookup('secondary_nfs_servers', {'default_value' => []}),
    Stdlib::Host $scratch_active_server = lookup('scratch_active_server'),
    # The following is intentionally using the same value as for scratch.  This may not always
    # be desireable, so a separate parameter is offered.
    Stdlib::Host $maps_active_server = lookup('scratch_active_server'),
) {

    # TODO: Change these "secondary" mentions to "primary"
    # The primary cluster is mounted as secondary for historical reasons and
    # changing this would be quite disruptive so put off for a while.
    labstore::nfs_mount { 'project-on-labstore-secondary':
        mount_name  => 'project',
        project     => $::labsproject,
        options     => ['rw', $mode],
        mount_path  => '/mnt/nfs/labstore-secondary-project',
        share_path  => "/srv/misc/shared/${::labsproject}/project",
        server      => 'nfs-tools-project.svc.eqiad.wmnet',
        lookupcache => $lookupcache,
        nfs_version => $nfs_version,
    }

    labstore::nfs_mount { 'home-on-labstore-secondary':
        mount_name  => 'home',
        project     => $::labsproject,
        options     => ['rw', $home_mode],
        mount_path  => '/mnt/nfs/labstore-secondary-home',
        share_path  => "/srv/misc/shared/${::labsproject}/home",
        server      => 'nfs-tools-project.svc.eqiad.wmnet',
        lookupcache => $lookupcache,
        nfs_version => $nfs_version,
    }

    if mount_nfs_volume($::labsproject, 'project') {
        file { '/data/project':
            ensure  => 'link',
            force   => true,
            target  => '/mnt/nfs/labstore-secondary-project',
            require => Labstore::Nfs_mount['project-on-labstore-secondary'],
        }
    }

    if mount_nfs_volume($::labsproject, 'home') {
        file { '/home':
            ensure  => 'link',
            force   => true,
            target  => '/mnt/nfs/labstore-secondary-home',
            require => Labstore::Nfs_mount['home-on-labstore-secondary'],
        }
    }

    # These are actually the secondary servers, not the servers formerly known as
    # secondary.  These are not connected to the above TODO
    $secondary_servers.each |String $server| {
        labstore::nfs_mount { $server:
            mount_name  => 'scratch',
            project     => $::labsproject,
            options     => ['rw', 'soft', 'timeo=300', 'retrans=3'],
            mount_path  => "/mnt/nfs/secondary-${server}-scratch",
            share_path  => '/srv/scratch',
            server      => $server,
            lookupcache => $lookupcache,
            nfs_version => $nfs_version,
        }
    }
    if mount_nfs_volume($::labsproject, 'scratch') {
        file { '/data/scratch':
            ensure  => 'link',
            target  => "/mnt/nfs/secondary-${scratch_active_server}-scratch",
            require => Labstore::Nfs_mount[$scratch_active_server]
        }
    }

    if $::labsproject == 'maps' {

        labstore::nfs_mount { 'maps-on-secondary':
            mount_name  => 'maps',
            project     => $::labsproject,
            options     => ['rw', $home_mode],  # Careful with mode on maps - /home is there
            mount_path  => '/mnt/nfs/secondary-maps',
            server      => 'nfs-maps.wikimedia.org',
            share_path  => '/srv/maps',
            lookupcache => $lookupcache,
            nfs_version => $nfs_version,
        }

        if mount_nfs_volume($::labsproject, 'maps') {

            file { '/data/project':
                ensure  => 'link',
                force   => true,
                target  => '/mnt/nfs/secondary-maps/project',
                require => Labstore::Nfs_mount['maps-on-secondary'],
            }

            file { '/home':
                ensure  => 'link',
                force   => true,
                target  => '/mnt/nfs/secondary-maps/home',
                require => Labstore::Nfs_mount['maps-on-secondary'],
            }
        }
    }

    # Only set the $mode on tools where you really know what you are doing.
    # /data/project there is the home directory for tools so it should never
    # be set on the grid or most worker nodes. Only set that to soft when it is
    # a special purpose instance that uses it for backup or similar.
    if $::labsproject == 'tools' {

        labstore::nfs_mount { 'tools-home-on-labstore-secondary':
            mount_name  => 'tools-home',
            project     => $::labsproject,
            options     => ['rw', $mode],
            mount_path  => '/mnt/nfs/labstore-secondary-tools-home',
            server      => 'nfs-tools-project.svc.eqiad.wmnet',
            share_path  => '/srv/tools/shared/tools/home',
            lookupcache => $lookupcache,
            nfs_version => $nfs_version,
        }

        labstore::nfs_mount { 'tools-project-on-labstore-secondary':
            mount_name  => 'tools-project',
            project     => $::labsproject,
            options     => ['rw', $home_mode],
            mount_path  => '/mnt/nfs/labstore-secondary-tools-project',
            server      => 'nfs-tools-project.svc.eqiad.wmnet',
            share_path  => '/srv/tools/shared/tools/project',
            lookupcache => $lookupcache,
            nfs_version => $nfs_version,
        }

        # Sets up symlinks from new tools mounts to /data/project and /home
        if mount_nfs_volume($::labsproject, 'tools-project') {
            file { '/data/project':
                ensure  => 'link',
                force   => true,
                target  => '/mnt/nfs/labstore-secondary-tools-project',
                require => Labstore::Nfs_mount['tools-project-on-labstore-secondary'],
            }
        }
        if mount_nfs_volume($::labsproject, 'tools-home') {
            file { '/home':
                ensure  => 'link',
                force   => true,
                target  => '/mnt/nfs/labstore-secondary-tools-home',
                require => Labstore::Nfs_mount['tools-home-on-labstore-secondary'],
            }
        }
    }

    $dumps_servers.each |String $server| {
        labstore::nfs_mount { $server:
            mount_name  => 'dumps',
            project     => $::labsproject,
            options     => ['ro', 'soft', 'timeo=300', 'retrans=3'],
            mount_path  => "/mnt/nfs/dumps-${server}",
            share_path  => '',
            server      => $server,
            lookupcache => $lookupcache,
            nfs_version => $nfs_version,
        }
    }

    if mount_nfs_volume($::labsproject, 'dumps') {

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

        $dumps_share_root = "/mnt/nfs/dumps-${dumps_active_server}"

        $defaults = {
            ensure => 'link',
            require => Labstore::Nfs_mount[$dumps_active_server]
        }

        $symlinks = {
            '/public/dumps/public' => {
                target  => "${dumps_share_root}/",
            },
            '/public/dumps/incr' => {
                target  => "${dumps_share_root}/other/incr",
            },
            '/public/dumps/pagecounts-all-sites' => {
                target  => "${dumps_share_root}/other/pagecounts-all-sites",
            },
            '/public/dumps/pagecounts-raw' => {
                target  => "${dumps_share_root}/other/pagecounts-raw",
            },
            '/public/dumps/pageviews' => {
                target  => "${dumps_share_root}/other/pageviews",
            },
        }

        create_resources(file, $symlinks, $defaults)
    }
}