Puppet Class: swift::ring_manager

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

Overview

Class swift::ring_manager

management of swift rings Alongside the configuration file for the relevant cluster, a Systemd timer to run swift_ring_manager, and rsync server to provide rings to the puppetmasters

Parameters:

  • swift_cluster (String)

    Name of the swift cluster

  • ensure (Wmflib::Ensure) (defaults to: 'absent')

    present/absent to install/remove checkout/config/timer

  • puppetmasters (Array[String]) (defaults to: [])

    Array of servers to allow rsync from

  • install_dir (Stdlib::Unixpath) (defaults to: '/srv/deployment/swift_ring_manager')
  • ring_dir (Optional[Stdlib::Unixpath]) (defaults to: '/var/cache/swift_rings')


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

class swift::ring_manager (
    String           $swift_cluster,
    Wmflib::Ensure   $ensure = 'absent',
    Array[String]    $puppetmasters = [],
    Stdlib::Unixpath $install_dir = '/srv/deployment/swift_ring_manager',
    Optional[Stdlib::Unixpath] $ring_dir = '/var/cache/swift_rings',
) {

    #pre-bullseye, we want python to run swift_ring_manager, & python-yaml
    #bullseye and later, use python3 and python3-yaml
    $python = debian::codename::lt('bullseye') ? {
        true  => 'python',
        false => 'python3',
    }
    $yaml_package = "${python}-yaml"
    ensure_packages($yaml_package)

    # install_dir is managed by git::clone
    wmflib::dir::mkdir_p([$install_dir.dirname(), $ring_dir])

    $git_ensure = $ensure ? {
        absent  => 'absent',
        present => 'latest',
    }
    git::clone { 'swift_ring_manager':
        ensure    => $git_ensure,
        directory => $install_dir,
        origin    => 'https://gitlab.wikimedia.org/mvernon/swift-ring',
        branch    => 'main',
        }

    file { '/etc/swift/hosts.yaml':
        ensure => $ensure,
        source => "puppet:///modules/swift/${swift_cluster}_hosts.yaml",
    }

    #Wrapper that runs swift_ring_manager.py with the correct python
    #This means that we can use syslog matching in process name too
    file { '/usr/local/bin/swift_ring_manager':
        ensure  => file,
        mode    => '0555',
        content => "#!/bin/sh\n/usr/bin/${python} ${install_dir}/swift_ring_manager.py \"$@\"",
    }

    systemd::timer::job { 'swift_ring_manager':
        ensure                    => $ensure,
        command                   => "/usr/local/bin/swift_ring_manager -o ${ring_dir} --doit --syslog",
        interval                  => {'start' => 'OnCalendar', 'interval' => '*:10:00'},
        monitoring_enabled        => true,
        monitoring_contact_groups => 'databases-testing',
        logfile_name              => 'swift_ring_manager.log',
        logfile_owner             => 'swift',
        user                      => 'root',
        description               => 'Swift ring manager',
    }

    rsync::server::module { 'swiftrings':
        ensure         => $ensure,
        read_only      => 'yes',
        hosts_allow    => $puppetmasters,
        auto_ferm      => true,
        auto_ferm_ipv6 => true,
        chroot         => false,
        path           => $ring_dir,
    }
}