Defined Type: labs_lvm::swap

Defined in:
modules/labs_lvm/manifests/swap.pp

Overview

define: labs_lvm::swap

Defines and activates a swap partition of a given size

Parameters

size

Size of swap partition to allocate. Can be string of form 16GB or 80%FREE

Parameters:

  • size (Any)


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
# File 'modules/labs_lvm/manifests/swap.pp', line 8

define labs_lvm::swap(
    $size,
) {

    include ::labs_lvm

    $volume_path = "/dev/vd/${name}"

    exec { "create-swap-${name}":
        require => [
            File['/usr/local/sbin/make-instance-vol'],
            Exec['create-volume-group']
        ],
        command => "/usr/local/sbin/make-instance-vol ${name} ${size} swap",
        unless  => "/sbin/lvdisplay -c | grep ${volume_path}",
    }

    mount { "mount-swap-${name}":
        ensure  => present,
        name    => '-',
        atboot  => true,
        device  => $volume_path,
        options => 'defaults',
        fstype  => 'swap',
        require => Exec["create-swap-${name}"],
        notify  => Exec["swapon-${name}"],
    }

    exec { "swapon-${name}":
        refreshonly => true,
        command     => "/sbin/swapon ${volume_path}",
    }
}