Defined Type: netplan::config

Defined in:
manifests/config.pp

Summary

Generate netplan YAML files

Overview

Create netplan YAML files from a Hash of data.

Examples:

Basic config

netplan::config { 'example-config':
  settings => {
    version => 2,
    renderer => networkd,
    ethernets => {
      eth0 => {
        dhcp4 => true,
      },
    },
  },
}

Parameters:

  • ensure (Enum['present','absent']) (defaults to: 'present')

    Ensure presence/absence of the resource

  • file_name (String) (defaults to: $title)

    The filename to use for the generated YAML file

  • priority (Variant[String, Integer[0]]) (defaults to: 90)

    The string/number prefixed to the generated YAML file

  • file (Stdlib::Absolutepath) (defaults to: "/etc/netplan/${priority}-${file_name}.yaml")

    The absolute path of the genrated YAML file

  • file_mode (String) (defaults to: '0600')

    The file permissions for the generated YAML file

  • header (String) (defaults to: '# This file is managed by Puppet. DO NOT EDIT.')

    The file header for the generated YAML file

  • settings (Hash) (defaults to: {})

    A hash of netplan settings to be included in the generated YAML file



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'manifests/config.pp', line 39

define netplan::config (
  Enum['present','absent'] $ensure = 'present',
  String $file_name = $title,
  Variant[String, Integer[0]] $priority = 90,
  Stdlib::Absolutepath $file = "/etc/netplan/${priority}-${file_name}.yaml",
  String $file_mode = '0600',
  String $header = '# This file is managed by Puppet. DO NOT EDIT.',
  Hash $settings = {},
) {
  $netplan_yaml = to_yaml({ network => $settings })
  file { $file:
    ensure  => $ensure,
    mode    => $file_mode,
    content => "${header}\n${netplan_yaml}",
    notify  => Exec['netplan_cmd'],
  }
}