Puppet Class: swift::storage

Defined in:
modules/swift/manifests/storage.pp

Overview

Parameters:

  • statsd_host (Any) (defaults to: undef)
  • statsd_port (Any) (defaults to: 8125)
  • statsd_metric_prefix (Any) (defaults to: undef)
  • statsd_sample_rate_factor (Any) (defaults to: '1')
  • memcached_servers (Any) (defaults to: ['127.0.0.1:11211'])
  • object_replicator_concurrency (Any) (defaults to: undef)


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
# File 'modules/swift/manifests/storage.pp', line 1

class swift::storage (
    $statsd_host                   = undef,
    $statsd_port                   = 8125,
    $statsd_metric_prefix          = undef,
    $statsd_sample_rate_factor     = '1',
    $memcached_servers             = ['127.0.0.1:11211'],
    $object_replicator_concurrency = undef,
) {
    package {
        [ 'swift-account',
          'swift-container',
          'swift-object',
    ]:
        ensure => present,
    }

    class { 'rsync::server':
        log_file => '/var/log/rsyncd.log',
    }

    rsync::server::module { 'account':
        uid             => 'swift',
        gid             => 'swift',
        max_connections => '5',
        path            => '/srv/swift-storage/',
        read_only       => 'no',
        lock_file       => '/var/lock/account.lock',
    }
    rsync::server::module { 'container':
        uid             => 'swift',
        gid             => 'swift',
        max_connections => '5',
        path            => '/srv/swift-storage/',
        read_only       => 'no',
        lock_file       => '/var/lock/container.lock',
    }
    rsync::server::module { 'object':
        uid             => 'swift',
        gid             => 'swift',
        max_connections => '20',
        path            => '/srv/swift-storage/',
        read_only       => 'no',
        lock_file       => '/var/lock/object.lock',
    }

    # set up swift specific configs
    File {
        owner => 'swift',
        group => 'swift',
        mode  => '0440',
    }

    file { '/etc/swift/account-server.conf':
        content => template('swift/account-server.conf.erb'),
    }

    file { '/etc/swift/container-server.conf':
        content => template('swift/container-server.conf.erb'),
    }

    file { '/etc/swift/object-server.conf':
        content => template('swift/object-server.conf.erb'),
    }

    file { '/etc/swift/container-reconciler.conf':
        content => template('swift/container-reconciler.conf.erb'),
    }

    file { '/srv/swift-storage':
        ensure  => directory,
        require => Package['swift'],
        owner   => 'swift',
        group   => 'swift',
        # the 1 is to allow nagios to read the drives for check_disk
        mode    => '0751',
    }

    service { [
        'swift-account',
        'swift-account-auditor',
        'swift-account-reaper',
        'swift-account-replicator',
        'swift-container',
        'swift-container-auditor',
        'swift-container-replicator',
        'swift-container-updater',
        'swift-object',
        'swift-object-auditor',
        'swift-object-replicator',
        'swift-object-updater',
    ]:
        ensure => running,
    }

    # Swift object reconstructor is needed for storage using erasures codes
    # which we don't use.

    # Remove its unit so 'systemctl <action> swift*' exits zero.
    # If one of the units matching the wildcard is masked then systemctl
    # exits non-zero on e.g. restart.
    file { '/lib/systemd/system/swift-object-reconstructor.service':
        ensure => absent,
        notify => Exec['reload systemd daemon'],
    }
    exec { 'reload systemd daemon':
        command     => '/bin/systemctl daemon-reload',
        refreshonly => true,
    }

    # install swift-drive-audit as a cronjob;
    # it checks the disks every 60 minutes
    # and unmounts failed disks. It logs its actions to /var/log/syslog.

    # this file comes from the python-swift package
    # but there are local improvements
    # that are not yet merged upstream.
    file { '/usr/bin/swift-drive-audit':
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
        source => 'puppet:///modules/swift/swift-drive-audit.py',
    }
    file { '/etc/swift/swift-drive-audit.conf':
        owner  => 'root',
        group  => 'root',
        mode   => '0440',
        source => 'puppet:///modules/swift/swift-drive-audit.conf',
    }
    cron { 'swift-drive-audit':
        ensure  => present,
        command => '/usr/bin/swift-drive-audit /etc/swift/swift-drive-audit.conf',
        user    => 'root',
        minute  => '1',
        require => [File['/usr/bin/swift-drive-audit'],
                    File['/etc/swift/swift-drive-audit.conf']],
    }

    udev::rule{ 'swift_disks':
        source => 'puppet:///modules/swift/swift_disks.rules',
    }
}