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. Depends-on: https://review.opendev.org/c/openstack/puppet-vswitch/+/886112 Change-Id: I8d01236c04cf2b61f1c1bf39ecf54ca0a67a33a9
This commit is contained in:
parent
e6d918f616
commit
02512cccbc
9
data/Debian-family.yaml
Normal file
9
data/Debian-family.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
ovn::controller::package_name: 'ovn-host'
|
||||||
|
ovn::controller::service_name: 'ovn-host'
|
||||||
|
ovn::controller::config_file_path: '/etc/default/ovn-host'
|
||||||
|
ovn::controller::config_option_name: 'OVN_CTL_OPTS'
|
||||||
|
ovn::northd::package_name: 'ovn-central'
|
||||||
|
ovn::northd::service_name: 'ovn-central'
|
||||||
|
ovn::northd::config_file_path: '/etc/default/ovn-central'
|
||||||
|
ovn::northd::config_option_name: 'OVN_CTL_OPTS'
|
9
data/RedHat-family.yaml
Normal file
9
data/RedHat-family.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
ovn::controller::package_name: 'openvswitch-ovn-host'
|
||||||
|
ovn::controller::service_name: 'ovn-controller'
|
||||||
|
ovn::controller::config_file_path: '/etc/sysconfig/ovn-controller'
|
||||||
|
ovn::controller::config_option_name: 'OVN_CONTROLLER_OPTS'
|
||||||
|
ovn::northd::package_name: 'openvswitch-ovn-central'
|
||||||
|
ovn::northd::service_name: 'ovn-northd'
|
||||||
|
ovn::northd::config_file_path: '/etc/sysconfig/ovn-northd'
|
||||||
|
ovn::northd::config_option_name: 'OVN_NORTHD_OPTS'
|
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'
|
@ -5,6 +5,19 @@
|
|||||||
#
|
#
|
||||||
# === Parameters:
|
# === Parameters:
|
||||||
#
|
#
|
||||||
|
# [*package_name*]
|
||||||
|
# (required) Name of ovn-controller package.
|
||||||
|
#
|
||||||
|
# [*service_name*]
|
||||||
|
# (required) Name of ovn-controller service.
|
||||||
|
#
|
||||||
|
# [*config_file_path*]
|
||||||
|
# (required) File path of the ovn-controller config file
|
||||||
|
#
|
||||||
|
# [*config_option_name*]
|
||||||
|
# (required) Name of the environment variable to customize options to launch
|
||||||
|
# the ovn-controller service.
|
||||||
|
#
|
||||||
# [*ovn_remote*]
|
# [*ovn_remote*]
|
||||||
# (Required) URL of the remote ovn southbound db.
|
# (Required) URL of the remote ovn southbound db.
|
||||||
# Example: 'tcp:127.0.0.1:6642'
|
# Example: 'tcp:127.0.0.1:6642'
|
||||||
@ -127,6 +140,10 @@
|
|||||||
# Defaults to []
|
# Defaults to []
|
||||||
#
|
#
|
||||||
class ovn::controller(
|
class ovn::controller(
|
||||||
|
String[1] $service_name,
|
||||||
|
String[1] $package_name,
|
||||||
|
Stdlib::Absolutepath $config_file_path,
|
||||||
|
String[1] $config_option_name,
|
||||||
String $ovn_remote,
|
String $ovn_remote,
|
||||||
String $ovn_encap_ip,
|
String $ovn_encap_ip,
|
||||||
String $package_ensure = 'present',
|
String $package_ensure = 'present',
|
||||||
@ -154,8 +171,6 @@ class ovn::controller(
|
|||||||
Array[String[1]] $ovn_controller_extra_opts = [],
|
Array[String[1]] $ovn_controller_extra_opts = [],
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include ovn::params
|
|
||||||
|
|
||||||
if $enable_dpdk and ! $datapath_type {
|
if $enable_dpdk and ! $datapath_type {
|
||||||
fail('Datapath type must be set when DPDK is enabled')
|
fail('Datapath type must be set when DPDK is enabled')
|
||||||
}
|
}
|
||||||
@ -170,15 +185,17 @@ class ovn::controller(
|
|||||||
|
|
||||||
service { 'controller':
|
service { 'controller':
|
||||||
ensure => true,
|
ensure => true,
|
||||||
name => $::ovn::params::ovn_controller_service_name,
|
name => $service_name,
|
||||||
enable => true,
|
enable => true,
|
||||||
subscribe => Vs_config['external_ids:ovn-remote']
|
subscribe => Vs_config['external_ids:ovn-remote'],
|
||||||
|
tag => 'ovn',
|
||||||
}
|
}
|
||||||
|
|
||||||
package { $::ovn::params::ovn_controller_package_name:
|
package { 'ovn-controller':
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
notify => Service['controller'],
|
notify => Service['controller'],
|
||||||
name => $::ovn::params::ovn_controller_package_name,
|
name => $package_name,
|
||||||
|
tag => 'ovn',
|
||||||
}
|
}
|
||||||
|
|
||||||
if $ovn_controller_ssl_key and $ovn_controller_ssl_cert and $ovn_controller_ssl_ca_cert {
|
if $ovn_controller_ssl_key and $ovn_controller_ssl_cert and $ovn_controller_ssl_ca_cert {
|
||||||
@ -196,9 +213,9 @@ class ovn::controller(
|
|||||||
$ovn_controller_opts = join($ovn_controller_ssl_opts + $ovn_controller_extra_opts, ' ')
|
$ovn_controller_opts = join($ovn_controller_ssl_opts + $ovn_controller_extra_opts, ' ')
|
||||||
|
|
||||||
augeas { 'config-ovn-controller':
|
augeas { 'config-ovn-controller':
|
||||||
context => $::ovn::params::ovn_controller_context,
|
context => "/files${config_file_path}",
|
||||||
changes => "set ${$::ovn::params::ovn_controller_option_name} '\"${ovn_controller_opts}\"'",
|
changes => "set ${config_option_name} '\"${ovn_controller_opts}\"'",
|
||||||
require => Package[$::ovn::params::ovn_controller_package_name],
|
require => Package['ovn-controller'],
|
||||||
notify => Service['controller'],
|
notify => Service['controller'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,21 @@
|
|||||||
#
|
#
|
||||||
# installs ovn package starts the ovn-northd service
|
# installs ovn package starts the ovn-northd service
|
||||||
#
|
#
|
||||||
|
# [*package_name*]
|
||||||
|
# (required) Name of ovn-northd package.
|
||||||
|
#
|
||||||
|
# [*service_name*]
|
||||||
|
# (required) Name of ovn-northd service.
|
||||||
|
#
|
||||||
|
# [*config_file_path*]
|
||||||
|
# (required) File path of the ovn-controller config file
|
||||||
|
#
|
||||||
|
# [*config_option_name*]
|
||||||
|
# (required) Name of the environment variable to customize options to launch
|
||||||
|
# the ovn-controller service.
|
||||||
|
#
|
||||||
# [*package_ensure*]
|
# [*package_ensure*]
|
||||||
# (Optional) State of the openvswitch package
|
# (Optional) State of the ovn-northd package
|
||||||
# Defaults to 'present'.
|
# Defaults to 'present'.
|
||||||
#
|
#
|
||||||
# [*dbs_listen_ip*]
|
# [*dbs_listen_ip*]
|
||||||
@ -68,6 +81,10 @@
|
|||||||
# Defaults to []
|
# Defaults to []
|
||||||
#
|
#
|
||||||
class ovn::northd(
|
class ovn::northd(
|
||||||
|
String[1] $package_name,
|
||||||
|
String[1] $service_name,
|
||||||
|
Stdlib::Absolutepath $config_file_path,
|
||||||
|
String[1] $config_option_name,
|
||||||
String $package_ensure = 'present',
|
String $package_ensure = 'present',
|
||||||
String $dbs_listen_ip = '0.0.0.0',
|
String $dbs_listen_ip = '0.0.0.0',
|
||||||
Optional[String] $dbs_cluster_local_addr = undef,
|
Optional[String] $dbs_cluster_local_addr = undef,
|
||||||
@ -85,7 +102,6 @@ class ovn::northd(
|
|||||||
Optional[Stdlib::Absolutepath] $ovn_sb_db_ssl_ca_cert = undef,
|
Optional[Stdlib::Absolutepath] $ovn_sb_db_ssl_ca_cert = undef,
|
||||||
Array[String] $ovn_northd_extra_opts = [],
|
Array[String] $ovn_northd_extra_opts = [],
|
||||||
) {
|
) {
|
||||||
include ovn::params
|
|
||||||
include vswitch::ovs
|
include vswitch::ovs
|
||||||
|
|
||||||
$dbs_listen_ip_real = normalize_ip_for_uri($dbs_listen_ip)
|
$dbs_listen_ip_real = normalize_ip_for_uri($dbs_listen_ip)
|
||||||
@ -212,24 +228,26 @@ class ovn::northd(
|
|||||||
' ')
|
' ')
|
||||||
|
|
||||||
augeas { 'config-ovn-northd':
|
augeas { 'config-ovn-northd':
|
||||||
context => $::ovn::params::ovn_northd_context,
|
context => "/files${config_file_path}",
|
||||||
changes => "set ${$::ovn::params::ovn_northd_option_name} '\"${ovn_northd_opts}\"'",
|
changes => "set ${config_option_name} '\"${ovn_northd_opts}\"'",
|
||||||
require => Package[$::ovn::params::ovn_northd_package_name],
|
require => Package['ovn-northd'],
|
||||||
before => Service['northd'],
|
before => Service['northd'],
|
||||||
}
|
}
|
||||||
|
|
||||||
service { 'northd':
|
service { 'northd':
|
||||||
ensure => true,
|
ensure => true,
|
||||||
enable => true,
|
enable => true,
|
||||||
name => $::ovn::params::ovn_northd_service_name,
|
name => $service_name,
|
||||||
require => Service['openvswitch']
|
require => Service['openvswitch'],
|
||||||
|
tag => 'ovn',
|
||||||
}
|
}
|
||||||
|
|
||||||
package { $::ovn::params::ovn_northd_package_name:
|
package { 'ovn-northd':
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
name => $::ovn::params::ovn_northd_package_name,
|
name => $package_name,
|
||||||
notify => Service['northd'],
|
notify => Service['northd'],
|
||||||
require => Package[$::vswitch::params::ovs_package_name]
|
require => Package['openvswitch'],
|
||||||
|
tag => 'ovn',
|
||||||
}
|
}
|
||||||
|
|
||||||
# NOTE(tkajinam): We have to escapte [ and ] otherwise egrep intereprets
|
# NOTE(tkajinam): We have to escapte [ and ] otherwise egrep intereprets
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
# ovn params
|
|
||||||
# == Class: ovn::params
|
|
||||||
#
|
|
||||||
# This class defines the variable like
|
|
||||||
#
|
|
||||||
class ovn::params {
|
|
||||||
include openstacklib::defaults
|
|
||||||
case $facts['os']['family'] {
|
|
||||||
'RedHat': {
|
|
||||||
$ovn_northd_package_name = 'openvswitch-ovn-central'
|
|
||||||
$ovn_controller_package_name = 'openvswitch-ovn-host'
|
|
||||||
$ovn_northd_service_name = 'ovn-northd'
|
|
||||||
$ovn_northd_context = '/files/etc/sysconfig/ovn-northd'
|
|
||||||
$ovn_northd_option_name = 'OVN_NORTHD_OPTS'
|
|
||||||
$ovn_controller_service_name = 'ovn-controller'
|
|
||||||
$ovn_controller_context = '/files/etc/sysconfig/ovn-controller'
|
|
||||||
$ovn_controller_option_name = 'OVN_CONTROLLER_OPTS'
|
|
||||||
}
|
|
||||||
'Debian': {
|
|
||||||
$ovn_northd_package_name = 'ovn-central'
|
|
||||||
$ovn_controller_package_name = 'ovn-host'
|
|
||||||
$ovn_northd_service_name = 'ovn-central'
|
|
||||||
$ovn_northd_context = '/files/etc/default/ovn-central'
|
|
||||||
$ovn_northd_option_name = 'OVN_CTL_OPTS'
|
|
||||||
$ovn_controller_service_name = 'ovn-host'
|
|
||||||
$ovn_controller_context = '/files/etc/default/ovn-host'
|
|
||||||
$ovn_controller_option_name = 'OVN_CTL_OPTS'
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
fail " Osfamily ${facts['os']['family']} not supported yet"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,10 +10,6 @@ describe 'ovn::controller' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for 'ovn controller' do
|
shared_examples_for 'ovn controller' do
|
||||||
it 'includes params' do
|
|
||||||
is_expected.to contain_class('ovn::params')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'includes controller' do
|
it 'includes controller' do
|
||||||
is_expected.to contain_class('ovn::controller')
|
is_expected.to contain_class('ovn::controller')
|
||||||
end
|
end
|
||||||
@ -27,7 +23,7 @@ describe 'ovn::controller' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'installs controller package' do
|
it 'installs controller package' do
|
||||||
is_expected.to contain_package(platform_params[:ovn_controller_package_name]).with(
|
is_expected.to contain_package('ovn-controller').with(
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:name => platform_params[:ovn_controller_package_name],
|
:name => platform_params[:ovn_controller_package_name],
|
||||||
:notify => 'Service[controller]'
|
:notify => 'Service[controller]'
|
||||||
|
@ -224,10 +224,6 @@ describe 'ovn::northd' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for 'ovn northd' do
|
shared_examples_for 'ovn northd' do
|
||||||
it 'includes params' do
|
|
||||||
is_expected.to contain_class('ovn::params')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'starts northd' do
|
it 'starts northd' do
|
||||||
is_expected.to contain_service('northd').with(
|
is_expected.to contain_service('northd').with(
|
||||||
:ensure => true,
|
:ensure => true,
|
||||||
@ -237,7 +233,7 @@ describe 'ovn::northd' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'installs package' do
|
it 'installs package' do
|
||||||
is_expected.to contain_package(platform_params[:ovn_northd_package_name]).with(
|
is_expected.to contain_package('ovn-northd').with(
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:name => platform_params[:ovn_northd_package_name],
|
:name => platform_params[:ovn_northd_package_name],
|
||||||
:notify => 'Service[northd]'
|
:notify => 'Service[northd]'
|
||||||
|
Loading…
Reference in New Issue
Block a user