diff --git a/manifests/ovs.pp b/manifests/ovs.pp index 04a92b1a..09550507 100644 --- a/manifests/ovs.pp +++ b/manifests/ovs.pp @@ -47,29 +47,6 @@ class vswitch::ovs( } } - case $::operatingsystem { - 'Ubuntu': { - # ubuntu 16.04 doesn't have upstart - # this workaround should be removed when https://bugs.launchpad.net/ubuntu/+source/openvswitch/+bug/1585201 - # will be resolved - if versioncmp($::operatingsystemmajrelease, '16') >= 0 { - $ovs_status = '/etc/init.d/openvswitch-switch status | fgrep -q "not running"; if [ $? -eq 0 ]; then exit 1; else exit 0; fi' - } else { - $ovs_status = '/sbin/status openvswitch-switch | fgrep "start/running"' - } - } - default: { - $ovs_status = '/etc/init.d/openvswitch-switch status | fgrep -q "not running"; if [ $? -eq 0 ]; then exit 1; else exit 0; fi' - } - } - service { 'openvswitch': - ensure => true, - enable => true, - name => $::vswitch::params::ovs_service_name, - hasstatus => false, # the supplied command returns true even if it's not running - status => $ovs_status, - } - if $::ovs_version { $major_version = regsubst($::ovs_version, '^(\d+).*', '\1') if $major_version == '1' { @@ -80,51 +57,35 @@ class vswitch::ovs( } } - 'Redhat': { - service { 'openvswitch': - ensure => true, - enable => true, - name => $::vswitch::params::ovs_service_name, - } - } 'FreeBSD': { Package { provider => 'pkgng', } - service { 'ovsdb-server': - ensure => true, - enable => true, - name => $::vswitch::params::ovsdb_service_name, - status => $::vswitch::params::ovsdb_status, - } - ~> - service { 'openvswitch': - ensure => true, - enable => true, - name => $::vswitch::params::ovs_service_name, - status => $::vswitch::params::ovs_status, - } - } - 'Solaris': { - service { 'ovsdb-server': - ensure => true, - enable => true, - name => $::vswitch::params::ovsdb_service_name, - status => $::vswitch::params::ovsdb_status, - } - ~> - service { 'openvswitch': - ensure => true, - enable => true, - name => $::vswitch::params::ovs_service_name, - status => $::vswitch::params::ovs_status, - } } default: { - fail( "${::osfamily} not yet supported by puppet-vswitch") + # to appease the lint gods. } } + service { 'openvswitch': + ensure => true, + enable => true, + name => $::vswitch::params::ovs_service_name, + status => $::vswitch::params::ovs_status, + hasstatus => $::vswitch::params::ovs_service_hasstatus + } + + if $::vswitch::params::ovsdb_service_name { + service { 'ovsdb-server': + ensure => true, + enable => true, + name => $::vswitch::params::ovsdb_service_name, + status => $::vswitch::params::ovsdb_status, + } + + Service['ovsdb-server'] ~> Service['openvswitch'] + } + package { $::vswitch::params::ovs_package_name: ensure => $package_ensure, before => Service['openvswitch'], diff --git a/manifests/params.pp b/manifests/params.pp index 847a1a5e..8750224e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -25,6 +25,30 @@ class vswitch::params { $ovs_dkms_package_name = 'openvswitch-datapath-dkms' $ovs_service_name = 'openvswitch-switch' $provider = 'ovs' + case $::operatingsystem { + 'ubuntu': { + # ubuntu 16.04 doesn't have upstart + # this workaround should be removed when https://bugs.launchpad.net/ubuntu/+source/openvswitch/+bug/1585201 + # will be resolved + if versioncmp($::operatingsystemmajrelease, '16') >= 0 { + $ovs_status = '/etc/init.d/openvswitch-switch status | fgrep -q "not running"; if [ $? -eq 0 ]; then exit 1; else exit 0; fi' + } else { + $ovs_status = '/sbin/status openvswitch-switch | fgrep "start/running"' + } + $ovs_service_hasstatus = false + } + 'debian': { + if ($::lsbdistcodename == 'wheezy') { + $ovs_service_hasstatus = false + $ovs_status = '/etc/init.d/openvswitch-switch status | fgrep -q "not running"; if [ $? -eq 0 ]; then exit 1; else exit 0; fi' # lint:ignore:140chars + } else { + $ovs_service_hasstatus = true + } + } + default: { + fail('Unsupported Debian based system') + } + } } 'FreeBSD': { $ovs_package_name = 'openvswitch' diff --git a/releasenotes/notes/ovs-debian-6eb866a703b1ced5.yaml b/releasenotes/notes/ovs-debian-6eb866a703b1ced5.yaml new file mode 100644 index 00000000..35636007 --- /dev/null +++ b/releasenotes/notes/ovs-debian-6eb866a703b1ced5.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - Updates to service options for ovs when running under Debian jessie to + not restart ovs on each puppet run. diff --git a/spec/classes/vswitch_ovs_spec.rb b/spec/classes/vswitch_ovs_spec.rb index a717d109..2a029395 100644 --- a/spec/classes/vswitch_ovs_spec.rb +++ b/spec/classes/vswitch_ovs_spec.rb @@ -261,8 +261,7 @@ describe 'vswitch::ovs' do :ovs_dkms_package_name => 'openvswitch-datapath-dkms', :ovs_service_name => 'openvswitch-switch', :provider => 'ovs', - :service_hasstatus => false, - :service_status => '/etc/init.d/openvswitch-switch status | fgrep -q "not running"; if [ $? -eq 0 ]; then exit 1; else exit 0; fi', + :service_hasstatus => true, } elsif facts[:operatingsystem] == 'Ubuntu' {