Defined Type: docker::network

Defined in:
modules/docker/manifests/network.pp

Summary

Manage a Docker network

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • ensure (Wmflib::Ensure)

    Ensure of the resources that support it

  • subnet (Stdlib::IP::Address)

    Network subnet. Note that if multiple docker::network resources are defined, they must not specify overlapping subnets.

  • driver (Enum['bridge', 'overlay']) (defaults to: 'bridge')

    Network driver (bridge, overlay)



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'modules/docker/manifests/network.pp', line 8

define docker::network(
    Wmflib::Ensure $ensure,
    Stdlib::IP::Address $subnet,
    Enum['bridge', 'overlay'] $driver = 'bridge',
) {
    if $ensure == 'present' {
        exec { "create-docker-network-${title}":
            command => @("CMD"/L$)
                /usr/bin/docker network create \
                --driver='${driver}' \
                --subnet='${subnet}' \
                '${title}'
                |- CMD
            ,
            unless  => "/usr/bin/docker network ls --format '{{.Name}}' | grep -q '^${title}$'",
        }
    } else {
        exec { "remove-docker-network-${title}":
            command => "/usr/bin/docker network rm '${title}'",
            onlyif  => "/usr/bin/docker network ls --format '{{.Name}}' | grep -q '^${title}$'",
        }
    }
}