From 4e9e55987d3c21ce99d50969f227e5055fe6bd3c Mon Sep 17 00:00:00 2001 From: Babu Shanmugam Date: Tue, 15 Nov 2016 12:05:49 +0000 Subject: [PATCH] Input DB listen IP address for the ovn-northd When ovn-northd is started, along with it ovsdb servers for the southbound and northbound databases are also started. Without additional options for the ovn-northd service, the DB servers will be listenting on 0.0.0.0. This patch creates a systemd environment file that will create the db listen options for the northd service. It also sets the other options db-nb-create-insecure-remote and db-sb-create-insecure-remote which are required to start the ovsdb-server's listening on TCP connections. Please see this commit [1] for more details. [1] - https://github.com/openvswitch/ovs/commit/84d0ca5d00fe01b29163236d48fa0f9105687149 Co-authored-by: Numan Siddique Change-Id: I99b1c3e0fe89b763be81db9b8c1c3b257be42e6e --- manifests/northd.pp | 15 ++++++++++++++- spec/classes/ovn_northd_spec.rb | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/manifests/northd.pp b/manifests/northd.pp index cdd9461..6d7da80 100644 --- a/manifests/northd.pp +++ b/manifests/northd.pp @@ -3,10 +3,23 @@ # # installs ovn package starts the ovn-northd service # -class ovn::northd() { +# [*dbs_listen_ip*] +# The IP-Address where OVN DBs should be listening +# Defaults to '0.0.0.0' +# +class ovn::northd($dbs_listen_ip = '0.0.0.0') { include ::ovn::params include ::vswitch::ovs + if $::osfamily == 'RedHat' { + augeas { 'sysconfig-ovn-northd': + context => '/files/etc/sysconfig/ovn-northd', + changes => "set OVN_NORTHD_OPTS '\"--db-nb-addr=${dbs_listen_ip} --db-sb-addr=${dbs_listen_ip} \ +--db-nb-create-insecure-remote=yes --db-sb-create-insecure-remote=yes\"'", + before => Service['northd'], + } + } + service { 'northd': ensure => true, enable => true, diff --git a/spec/classes/ovn_northd_spec.rb b/spec/classes/ovn_northd_spec.rb index 320377c..07d4307 100644 --- a/spec/classes/ovn_northd_spec.rb +++ b/spec/classes/ovn_northd_spec.rb @@ -2,6 +2,19 @@ require 'spec_helper' describe 'ovn::northd' do + shared_examples_for 'systemd env' do + it 'creates systemd conf' do + is_expected.to contain_file('/etc/sysconfig/ovn-northd').with( + :ensure => 'file', + :mode => '0644', + :owner => 'root', + :group => 'root', + :content => "OVN_NORTHD_OPTS=--db-nb-addr=0.0.0.0 --db-sb-addr=0.0.0.0 --db-nb-create-insecure-remote=yes --db-sb-create-insecure-remote=yes", + :before => 'Service[northd]', + ) + end + end + shared_examples_for 'ovn northd' do it 'includes params' do is_expected.to contain_class('ovn::params') @@ -56,6 +69,7 @@ describe 'ovn::northd' do } end it_behaves_like 'ovn northd' + it_behaves_like 'systemd env' end end end