Replace params by hieradata
The params class is the legacy approach to define OS/version specific values. This replaces the params class by the module hieradata following the recent standard. Change-Id: I046267279720e969b0ddde821fafff00e517e728
This commit is contained in:
parent
91231c2eea
commit
10f574dc53
5
data/Debian-family.yaml
Normal file
5
data/Debian-family.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
vswitch::dpdk::package_name: 'openvswitch-switch-dpdk'
|
||||||
|
vswitch::dpdk::service_name: 'openvswitch-switch'
|
||||||
|
vswitch::ovs::package_name: 'openvswitch-switch'
|
||||||
|
vswitch::ovs::service_name: 'openvswitch-switch'
|
5
data/RedHat-family.yaml
Normal file
5
data/RedHat-family.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
vswitch::dpdk::package_name: 'openvswitch'
|
||||||
|
vswitch::dpdk::service_name: 'openvswitch'
|
||||||
|
vswitch::ovs::package_name: 'openvswitch'
|
||||||
|
vswitch::ovs::service_name: 'openvswitch'
|
16
hiera.yaml
Normal file
16
hiera.yaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
version: 5
|
||||||
|
defaults:
|
||||||
|
datadir: 'data'
|
||||||
|
data_hash: 'yaml_data'
|
||||||
|
hierarchy:
|
||||||
|
- name: 'Major operating system version'
|
||||||
|
path: '%{facts.os.name}-%{facts.os.release.major}.yaml'
|
||||||
|
- name: 'Operating system'
|
||||||
|
path: '%{facts.os.release.major}.yaml'
|
||||||
|
- name: 'Major OS Family version'
|
||||||
|
path: '%{facts.os.family}-%{facts.os.release.major}.yaml'
|
||||||
|
- name: 'OS Family'
|
||||||
|
path: '%{facts.os.family}-family.yaml'
|
||||||
|
- name: 'Common'
|
||||||
|
path: 'common.yaml'
|
@ -3,6 +3,16 @@
|
|||||||
#
|
#
|
||||||
# === Parameters
|
# === Parameters
|
||||||
#
|
#
|
||||||
|
# [*package_name*]
|
||||||
|
# (required) Name of OVS DPDK package.
|
||||||
|
#
|
||||||
|
# [*service_name*]
|
||||||
|
# (required) Name of OVS service with DPDK functionality.
|
||||||
|
#
|
||||||
|
# [*package_ensure*]
|
||||||
|
# (Optional) State of the openvswitch package
|
||||||
|
# Defaults to 'present'.
|
||||||
|
#
|
||||||
# [*memory_channels*]
|
# [*memory_channels*]
|
||||||
# (optional) The number of memory channels to use as an integer.
|
# (optional) The number of memory channels to use as an integer.
|
||||||
#
|
#
|
||||||
@ -12,10 +22,6 @@
|
|||||||
# where c1, c2, etc are core indexes between 0 and 128.
|
# where c1, c2, etc are core indexes between 0 and 128.
|
||||||
# For example, to configure 3 cores the value should be "0-2"
|
# For example, to configure 3 cores the value should be "0-2"
|
||||||
#
|
#
|
||||||
# [*package_ensure*]
|
|
||||||
# (Optional) State of the openvswitch package
|
|
||||||
# Defaults to 'present'.
|
|
||||||
#
|
|
||||||
# [*pmd_core_list*]
|
# [*pmd_core_list*]
|
||||||
# (optional) The list of cores to be used by the DPDK PMD threads.
|
# (optional) The list of cores to be used by the DPDK PMD threads.
|
||||||
# The pmd_core_list is a string with format as <c1>[-c2][,c3[-c4],...] where
|
# The pmd_core_list is a string with format as <c1>[-c2][,c3[-c4],...] where
|
||||||
@ -97,9 +103,11 @@
|
|||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
#
|
#
|
||||||
class vswitch::dpdk (
|
class vswitch::dpdk (
|
||||||
|
String[1] $package_name,
|
||||||
|
String[1] $service_name,
|
||||||
|
String $package_ensure = 'present',
|
||||||
Optional[Variant[Integer[0], String]] $memory_channels = undef,
|
Optional[Variant[Integer[0], String]] $memory_channels = undef,
|
||||||
Optional[String] $host_core_list = undef,
|
Optional[String] $host_core_list = undef,
|
||||||
String $package_ensure = 'present',
|
|
||||||
Optional[String] $pmd_core_list = undef,
|
Optional[String] $pmd_core_list = undef,
|
||||||
Optional[Variant[String, Integer, Array[String], Array[Integer]]] $socket_mem = undef,
|
Optional[Variant[String, Integer, Array[String], Array[Integer]]] $socket_mem = undef,
|
||||||
Optional[Variant[String, Integer, Array[String], Array[Integer]]] $socket_limit = undef,
|
Optional[Variant[String, Integer, Array[String], Array[Integer]]] $socket_limit = undef,
|
||||||
@ -118,14 +126,13 @@ class vswitch::dpdk (
|
|||||||
Boolean $skip_restart = false,
|
Boolean $skip_restart = false,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include vswitch::params
|
|
||||||
|
|
||||||
$restart = !$skip_restart
|
$restart = !$skip_restart
|
||||||
|
|
||||||
kmod::load { 'vfio-pci': }
|
kmod::load { 'vfio-pci': }
|
||||||
|
|
||||||
package { $::vswitch::params::ovs_dpdk_package_name:
|
package { 'openvswitch':
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
|
name => $package_name,
|
||||||
before => Service['openvswitch'],
|
before => Service['openvswitch'],
|
||||||
tag => 'openvswitch',
|
tag => 'openvswitch',
|
||||||
}
|
}
|
||||||
@ -277,14 +284,15 @@ class vswitch::dpdk (
|
|||||||
service { 'openvswitch':
|
service { 'openvswitch':
|
||||||
ensure => true,
|
ensure => true,
|
||||||
enable => true,
|
enable => true,
|
||||||
name => $::vswitch::params::ovs_service_name,
|
name => $service_name,
|
||||||
|
tag => 'openvswitch',
|
||||||
}
|
}
|
||||||
|
|
||||||
# NOTE(tkajinam): This resource is defined to restart the openvswitch services
|
# NOTE(tkajinam): This resource is defined to restart the openvswitch services
|
||||||
# when any vs_config resource with restart => true is enabled.
|
# when any vs_config resource with restart => true is enabled.
|
||||||
exec { 'restart openvswitch':
|
exec { 'restart openvswitch':
|
||||||
path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
|
path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
|
||||||
command => "systemctl -q restart ${::vswitch::params::ovs_service_name}.service",
|
command => "systemctl -q restart ${service_name}.service",
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#
|
#
|
||||||
# [*provider*]
|
# [*provider*]
|
||||||
# Select vswitch to install
|
# Select vswitch to install
|
||||||
|
# Defaults to 'ovs'
|
||||||
#
|
#
|
||||||
# === Examples
|
# === Examples
|
||||||
#
|
#
|
||||||
@ -25,7 +26,7 @@
|
|||||||
# Apache License 2.0 (see LICENSE file)
|
# Apache License 2.0 (see LICENSE file)
|
||||||
#
|
#
|
||||||
class vswitch (
|
class vswitch (
|
||||||
Enum['ovs', 'dpdk'] $provider = $vswitch::params::provider
|
Enum['ovs', 'dpdk'] $provider = 'ovs'
|
||||||
) {
|
) {
|
||||||
$cls = "::vswitch::${provider}"
|
$cls = "::vswitch::${provider}"
|
||||||
include $cls
|
include $cls
|
||||||
|
@ -5,6 +5,12 @@
|
|||||||
#
|
#
|
||||||
# === Parameters:
|
# === Parameters:
|
||||||
#
|
#
|
||||||
|
# [*package_name*]
|
||||||
|
# (required) Name of OVS package.
|
||||||
|
#
|
||||||
|
# [*service_name*]
|
||||||
|
# (required) Name of OVS service.
|
||||||
|
#
|
||||||
# [*package_ensure*]
|
# [*package_ensure*]
|
||||||
# (Optional) State of the openvswitch package
|
# (Optional) State of the openvswitch package
|
||||||
# Defaults to 'present'.
|
# Defaults to 'present'.
|
||||||
@ -37,6 +43,8 @@
|
|||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
#
|
#
|
||||||
class vswitch::ovs(
|
class vswitch::ovs(
|
||||||
|
String[1] $package_name,
|
||||||
|
String[1] $service_name,
|
||||||
String $package_ensure = 'present',
|
String $package_ensure = 'present',
|
||||||
Boolean $enable_hw_offload = false,
|
Boolean $enable_hw_offload = false,
|
||||||
Boolean $disable_emc = false,
|
Boolean $disable_emc = false,
|
||||||
@ -45,8 +53,6 @@ class vswitch::ovs(
|
|||||||
Boolean $skip_restart = false,
|
Boolean $skip_restart = false,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include vswitch::params
|
|
||||||
|
|
||||||
$restart = !$skip_restart
|
$restart = !$skip_restart
|
||||||
|
|
||||||
if $enable_hw_offload {
|
if $enable_hw_offload {
|
||||||
@ -85,19 +91,21 @@ class vswitch::ovs(
|
|||||||
service { 'openvswitch':
|
service { 'openvswitch':
|
||||||
ensure => true,
|
ensure => true,
|
||||||
enable => true,
|
enable => true,
|
||||||
name => $::vswitch::params::ovs_service_name,
|
name => $service_name,
|
||||||
|
tag => 'openvswitch',
|
||||||
}
|
}
|
||||||
|
|
||||||
# NOTE(tkajinam): This resource is defined to restart the openvswitch service
|
# NOTE(tkajinam): This resource is defined to restart the openvswitch service
|
||||||
# when any vs_config resource with restart => true is enabled.
|
# when any vs_config resource with restart => true is enabled.
|
||||||
exec { 'restart openvswitch':
|
exec { 'restart openvswitch':
|
||||||
path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
|
path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
|
||||||
command => "systemctl -q restart ${::vswitch::params::ovs_service_name}.service",
|
command => "systemctl -q restart ${service_name}.service",
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
}
|
}
|
||||||
|
|
||||||
package { $::vswitch::params::ovs_package_name:
|
package { 'openvswitch':
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
|
name => $package_name,
|
||||||
before => Service['openvswitch'],
|
before => Service['openvswitch'],
|
||||||
tag => 'openvswitch',
|
tag => 'openvswitch',
|
||||||
}
|
}
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
# vswitch params
|
|
||||||
#
|
|
||||||
class vswitch::params {
|
|
||||||
include openstacklib::defaults
|
|
||||||
|
|
||||||
case $facts['os']['family'] {
|
|
||||||
'Redhat': {
|
|
||||||
$ovs_package_name = 'openvswitch'
|
|
||||||
# OVS2.5 in Red Hat family is unified package which will support plain
|
|
||||||
# OVS and also DPDK (if enabled at runtime).
|
|
||||||
$ovs_dpdk_package_name = 'openvswitch'
|
|
||||||
$ovs_service_name = 'openvswitch'
|
|
||||||
$provider = 'ovs'
|
|
||||||
}
|
|
||||||
'Debian': {
|
|
||||||
$ovs_package_name = 'openvswitch-switch'
|
|
||||||
$ovs_dpdk_package_name = 'openvswitch-switch-dpdk'
|
|
||||||
$ovs_service_name = 'openvswitch-switch'
|
|
||||||
$provider = 'ovs'
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
fail " Osfamily ${facts['os']['family']} not supported yet"
|
|
||||||
}
|
|
||||||
} # Case $facts['os']['family']
|
|
||||||
}
|
|
@ -3,7 +3,6 @@
|
|||||||
# Initialize CA authority
|
# Initialize CA authority
|
||||||
#
|
#
|
||||||
class vswitch::pki::cacert {
|
class vswitch::pki::cacert {
|
||||||
include vswitch::params
|
|
||||||
|
|
||||||
exec { 'ovs-pki-init-ca-authority':
|
exec { 'ovs-pki-init-ca-authority':
|
||||||
command => 'ovs-pki init --force',
|
command => 'ovs-pki init --force',
|
||||||
@ -11,6 +10,6 @@ class vswitch::pki::cacert {
|
|||||||
path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],
|
path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],
|
||||||
}
|
}
|
||||||
|
|
||||||
Package<| title == $::vswitch::params::ovs_package_name |>
|
Package<| title == 'openvswitch' |>
|
||||||
-> Exec['ovs-pki-init-ca-authority']
|
-> Exec['ovs-pki-init-ca-authority']
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
define vswitch::pki::cert(
|
define vswitch::pki::cert(
|
||||||
Stdlib::Absolutepath $cert_dir = '/etc/openvswitch',
|
Stdlib::Absolutepath $cert_dir = '/etc/openvswitch',
|
||||||
) {
|
) {
|
||||||
include vswitch::params
|
|
||||||
|
|
||||||
exec { "ovs-req-and-sign-cert-${name}":
|
exec { "ovs-req-and-sign-cert-${name}":
|
||||||
command => "ovs-pki req+sign ${name}",
|
command => "ovs-pki req+sign ${name}",
|
||||||
@ -20,7 +19,7 @@ define vswitch::pki::cert(
|
|||||||
path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],
|
path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],
|
||||||
}
|
}
|
||||||
|
|
||||||
Package<| title == $::vswitch::params::ovs_package_name |>
|
Package<| title == 'openvswitch' |>
|
||||||
-> Exec["ovs-req-and-sign-cert-${name}"]
|
-> Exec["ovs-req-and-sign-cert-${name}"]
|
||||||
|
|
||||||
Exec<| title == 'ovs-pki-init-ca-authority' |>
|
Exec<| title == 'ovs-pki-init-ca-authority' |>
|
||||||
|
@ -57,14 +57,16 @@ describe 'vswitch::dpdk' do
|
|||||||
:ensure => true,
|
:ensure => true,
|
||||||
:enable => true,
|
:enable => true,
|
||||||
:name => platform_params[:ovs_service_name],
|
:name => platform_params[:ovs_service_name],
|
||||||
|
:tag => 'openvswitch'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'install package' do
|
it 'install package' do
|
||||||
is_expected.to contain_package(platform_params[:ovs_dpdk_package_name]).with(
|
is_expected.to contain_package('openvswitch').with(
|
||||||
:name => platform_params[:ovs_dpdk_package_name],
|
:name => platform_params[:ovs_dpdk_package_name],
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:before => 'Service[openvswitch]'
|
:before => 'Service[openvswitch]',
|
||||||
|
:tag => 'openvswitch'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,10 +9,6 @@ describe 'vswitch::ovs' do
|
|||||||
is_expected.to contain_class('vswitch::ovs')
|
is_expected.to contain_class('vswitch::ovs')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'contains params' do
|
|
||||||
is_expected.to contain_class('vswitch::params')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'clears hw-offload option' do
|
it 'clears hw-offload option' do
|
||||||
is_expected.to contain_vs_config('other_config:hw-offload').with(
|
is_expected.to contain_vs_config('other_config:hw-offload').with(
|
||||||
:ensure => 'absent', :restart => true, :wait => true,
|
:ensure => 'absent', :restart => true, :wait => true,
|
||||||
@ -36,14 +32,16 @@ describe 'vswitch::ovs' do
|
|||||||
:ensure => true,
|
:ensure => true,
|
||||||
:enable => true,
|
:enable => true,
|
||||||
:name => platform_params[:ovs_service_name],
|
:name => platform_params[:ovs_service_name],
|
||||||
|
:tag => 'openvswitch'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'install package' do
|
it 'install package' do
|
||||||
is_expected.to contain_package(platform_params[:ovs_package_name]).with(
|
is_expected.to contain_package('openvswitch').with(
|
||||||
:name => platform_params[:ovs_package_name],
|
:name => platform_params[:ovs_package_name],
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:before => 'Service[openvswitch]'
|
:before => 'Service[openvswitch]',
|
||||||
|
:tag => 'openvswitch'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -66,10 +64,11 @@ describe 'vswitch::ovs' do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
it 'installs correct package' do
|
it 'installs correct package' do
|
||||||
is_expected.to contain_package(platform_params[:ovs_package_name]).with(
|
is_expected.to contain_package('openvswitch').with(
|
||||||
:name => platform_params[:ovs_package_name],
|
:name => platform_params[:ovs_package_name],
|
||||||
:ensure => 'latest',
|
:ensure => 'latest',
|
||||||
:before => 'Service[openvswitch]'
|
:before => 'Service[openvswitch]',
|
||||||
|
:tag => 'openvswitch'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
it 'configures hw-offload option' do
|
it 'configures hw-offload option' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user