Defined Type: interface::pre_down_command

Defined in:
modules/interface/manifests/pre_down_command.pp

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • interface (String[1])
  • command (String[1])
  • ensure (Wmflib::Ensure) (defaults to: 'present')


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'modules/interface/manifests/pre_down_command.pp', line 2

define interface::pre_down_command(
    String[1]      $interface,
    String[1]      $command,
    Wmflib::Ensure $ensure = 'present',
) {
    if $ensure == 'absent' {
        file_line { "rm_pre-down_${interface}_${title}":
            ensure            => absent,
            path              => '/etc/network/interfaces',
            match             => "pre-down ${command}",
            match_for_absence => true,
        }
    } else {
        # Use augeas to add an 'pre-down' command to the interface
        augeas { "pre-down_${interface}_${title}":
            incl    => '/etc/network/interfaces',
            lens    => 'Interfaces.lns',
            context => "/files/etc/network/interfaces/*[. = '${interface}']",
            changes => "set pre-down[last()+1] '${command}'",
            onlyif  => "match pre-down[. = '${command}'] size == 0";
        }
    }
}