File: node.pp

package info (click to toggle)
puppet-module-swift 25.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,400 kB
  • sloc: ruby: 9,593; python: 38; sh: 10; makefile: 10
file content (98 lines) | stat: -rw-r--r-- 2,685 bytes parent folder | download
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
#
# Builds out a default storage node
#   a storage node is a device that contains
#   a storage endpoint for account, container, and object
#   on the same mount point
#
# === Parameters:
#
# [*mnt_base_dir*]
#   (optional) The directory where the flat files that store the file system
#   to be loop back mounted are actually mounted at.
#   Defaults to '/srv/node', base directory where disks are mounted to
#
# [*zone*]
#   (required) Zone is the number of the zone this device is in.
#   The zone parameter must be an integer.
#
# [*weight*]
#   (optional) Weight is a float weight that determines how many partitions are
#   put on the device relative to the rest of the devices in the cluster (a good
#   starting point is 100.0xTB on the drive).
#   Add each device that will be initially in the cluster.
#   Defaults to 1.
#
# [*owner*]
#   (optional) Owner (uid) of rsync server.
#   Defaults to $::swift::params::user.
#
# [*group*]
#   (optional) Group (gid) of rsync server.
#   Defaults to $::swift::params::group.
#
# [*max_connections*]
#   (optional) maximum number of simultaneous connections allowed.
#   Defaults to 25.
#
# [*storage_local_net_ip*]
#   (optional) The IP address of the storage server.
#   Defaults to '127.0.0.1'.
#
#  [*policy_index*]
#    (optional) storage policy index
#    Defaults to undef
define swift::storage::node(
  $mnt_base_dir,
  Variant[Integer, Pattern[/^\d+$/]] $zone,
  $weight               = 1,
  $owner                = undef,
  $group                = undef,
  $max_connections      = 25,
  $storage_local_net_ip = '127.0.0.1',
  $policy_index         = undef,
) {

  include swift::deps

  Swift::Storage::Server {
    storage_local_net_ip => $storage_local_net_ip,
    devices              => $mnt_base_dir,
    max_connections      => $max_connections,
    owner                => pick($owner, $::swift::params::user),
    group                => pick($group, $::swift::params::group),
  }

  swift::storage::server { "60${name}0":
    type => 'object',
  }

  $ring_host = normalize_ip_for_uri($storage_local_net_ip)

  if !$policy_index {
    $ring_device = "${ring_host}:60${name}0/${name}"
  } else {
    $ring_device = "${policy_index}:${ring_host}:60${name}0/${name}"
  }

  ring_object_device { $ring_device:
    zone   => $zone,
    weight => $weight,
  }

  swift::storage::server { "60${name}1":
    type => 'container',
  }
  ring_container_device { "${ring_host}:60${name}1/${name}":
    zone   => $zone,
    weight => $weight,
  }

  swift::storage::server { "60${name}2":
    type => 'account',
  }
  ring_account_device { "${ring_host}:60${name}2/${name}":
    zone   => $zone,
    weight => $weight,
  }

}