Skip to content

Commit

Permalink
Merge "Replace params by hieradata"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Oct 31, 2023
2 parents 3a1996d + 02512cc commit 52d142d
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 62 deletions.
9 changes: 9 additions & 0 deletions data/Debian-family.yaml
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions data/RedHat-family.yaml
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -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'
35 changes: 26 additions & 9 deletions manifests/controller.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
#
# === 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*]
# (Required) URL of the remote ovn southbound db.
# Example: 'tcp:127.0.0.1:6642'
Expand Down Expand Up @@ -127,6 +140,10 @@
# Defaults to []
#
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_encap_ip,
String $package_ensure = 'present',
Expand Down Expand Up @@ -154,8 +171,6 @@
Array[String[1]] $ovn_controller_extra_opts = [],
) {

include ovn::params

if $enable_dpdk and ! $datapath_type {
fail('Datapath type must be set when DPDK is enabled')
}
Expand All @@ -170,15 +185,17 @@

service { 'controller':
ensure => true,
name => $::ovn::params::ovn_controller_service_name,
name => $service_name,
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,
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 {
Expand All @@ -196,9 +213,9 @@
$ovn_controller_opts = join($ovn_controller_ssl_opts + $ovn_controller_extra_opts, ' ')

augeas { 'config-ovn-controller':
context => $::ovn::params::ovn_controller_context,
changes => "set ${$::ovn::params::ovn_controller_option_name} '\"${ovn_controller_opts}\"'",
require => Package[$::ovn::params::ovn_controller_package_name],
context => "/files${config_file_path}",
changes => "set ${config_option_name} '\"${ovn_controller_opts}\"'",
require => Package['ovn-controller'],
notify => Service['controller'],
}

Expand Down
38 changes: 28 additions & 10 deletions manifests/northd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
#
# 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*]
# (Optional) State of the openvswitch package
# (Optional) State of the ovn-northd package
# Defaults to 'present'.
#
# [*dbs_listen_ip*]
Expand Down Expand Up @@ -68,6 +81,10 @@
# Defaults to []
#
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 $dbs_listen_ip = '0.0.0.0',
Optional[String] $dbs_cluster_local_addr = undef,
Expand All @@ -85,7 +102,6 @@
Optional[Stdlib::Absolutepath] $ovn_sb_db_ssl_ca_cert = undef,
Array[String] $ovn_northd_extra_opts = [],
) {
include ovn::params
include vswitch::ovs

$dbs_listen_ip_real = normalize_ip_for_uri($dbs_listen_ip)
Expand Down Expand Up @@ -212,24 +228,26 @@
' ')

augeas { 'config-ovn-northd':
context => $::ovn::params::ovn_northd_context,
changes => "set ${$::ovn::params::ovn_northd_option_name} '\"${ovn_northd_opts}\"'",
require => Package[$::ovn::params::ovn_northd_package_name],
context => "/files${config_file_path}",
changes => "set ${config_option_name} '\"${ovn_northd_opts}\"'",
require => Package['ovn-northd'],
before => Service['northd'],
}

service { 'northd':
ensure => true,
enable => true,
name => $::ovn::params::ovn_northd_service_name,
require => Service['openvswitch']
name => $service_name,
require => Service['openvswitch'],
tag => 'ovn',
}

package { $::ovn::params::ovn_northd_package_name:
package { 'ovn-northd':
ensure => $package_ensure,
name => $::ovn::params::ovn_northd_package_name,
name => $package_name,
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
Expand Down
33 changes: 0 additions & 33 deletions manifests/params.pp

This file was deleted.

6 changes: 1 addition & 5 deletions spec/classes/ovn_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
end

shared_examples_for 'ovn controller' do
it 'includes params' do
is_expected.to contain_class('ovn::params')
end

it 'includes controller' do
is_expected.to contain_class('ovn::controller')
end
Expand All @@ -27,7 +23,7 @@
end

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',
:name => platform_params[:ovn_controller_package_name],
:notify => 'Service[controller]'
Expand Down
6 changes: 1 addition & 5 deletions spec/classes/ovn_northd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,6 @@
end

shared_examples_for 'ovn northd' do
it 'includes params' do
is_expected.to contain_class('ovn::params')
end

it 'starts northd' do
is_expected.to contain_service('northd').with(
:ensure => true,
Expand All @@ -237,7 +233,7 @@
end

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',
:name => platform_params[:ovn_northd_package_name],
:notify => 'Service[northd]'
Expand Down

0 comments on commit 52d142d

Please sign in to comment.