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 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
# vswitch: open-vswitch
# == Class: vswitch::ovs
#
# installs openvswitch
#
# === Parameters:
#
# [*package_name*]
# (required) Name of OVS package.
#
# [*service_name*]
# (required) Name of OVS service.
#
# [*package_ensure*]
# (Optional) State of the openvswitch package
# Defaults to 'present'.
#
# [*enable_hw_offload*]
# (optional) Configure OVS to use
# Hardware Offload. This feature is
# supported from ovs 2.8.0.
# Defaults to false.
#
# [*disable_emc*]
# (optional) Configure OVS to disable EMC.
# Defaults to false.
#
# [*vlan_limit*]
# (optional) Number of vlan layers allowed.
# Default to undef
#
# [*vs_config*]
# (optional) allow configuration of arbitrary vswitch configurations.
# The value is an hash of vs_config resources. Example:
# { 'other_config:foo' => { value => 'baa' } }
# NOTE: that the configuration MUST NOT be already handled by this module
# or Puppet catalog compilation will fail with duplicate resources.
#
# [*skip_restart*]
# (optional) Skip restarting the service even when updating some options
# which require service restart. Setting this parameter to true avoids
# immedicate network distuption caused by restarting the ovs daemon.
# Defaults to false.
#
class vswitch::ovs(
String[1] $package_name,
String[1] $service_name,
String $package_ensure = 'present',
Boolean $enable_hw_offload = false,
Boolean $disable_emc = false,
Optional[Integer[0]] $vlan_limit = undef,
Hash $vs_config = {},
Boolean $skip_restart = false,
) {
$restart = !$skip_restart
if $enable_hw_offload {
vs_config { 'other_config:hw-offload':
value => true,
restart => $restart,
wait => true,
}
} else {
vs_config { 'other_config:hw-offload':
ensure => absent,
restart => $restart,
wait => true,
}
}
if $disable_emc {
vs_config { 'other_config:emc-insert-inv-prob':
value => 0,
wait => false,
}
} else {
vs_config { 'other_config:emc-insert-inv-prob':
ensure => absent,
wait => false,
}
}
vs_config { 'other_config:vlan-limit':
value => $vlan_limit,
wait => true,
}
create_resources('vs_config', $vs_config)
service { 'openvswitch':
ensure => true,
enable => true,
name => $service_name,
tag => 'openvswitch',
}
# NOTE(tkajinam): This resource is defined to restart the openvswitch service
# when any vs_config resource with restart => true is enabled.
exec { 'restart openvswitch':
path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
command => ['systemctl', '-q', 'restart', "${service_name}.service"],
refreshonly => true,
}
package { 'openvswitch':
ensure => $package_ensure,
name => $package_name,
before => Service['openvswitch'],
tag => 'openvswitch',
}
}
|