From 84b7c61586a49add0ad10cb4526593222236791f Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 4 May 2021 17:50:32 +0900 Subject: [PATCH] Manage octavia-driver-agent package/service ... since octavia-driver-agent is now packaged in Ubuntu and Debian. Change-Id: I07b12acbaba8eb8affc603c2679297495230d37a --- manifests/driver_agent.pp | 45 ++++++++++++++++++- manifests/params.pp | 4 ++ ...octavia-driver-agent-8b61e27e91e49b59.yaml | 5 +++ spec/classes/octavia_driver_agent_spec.rb | 25 ++++++++++- 4 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/octavia-driver-agent-8b61e27e91e49b59.yaml diff --git a/manifests/driver_agent.pp b/manifests/driver_agent.pp index 66ae1e60..6921b5e7 100644 --- a/manifests/driver_agent.pp +++ b/manifests/driver_agent.pp @@ -2,6 +2,18 @@ # # == Parameters # +# [*manage_service*] +# (optional) Whether the service should be managed by Puppet. +# Defaults to true. +# +# [*enabled*] +# (optional) Should the service be enabled. +# Defaults to true +# +# [*package_ensure*] +# (optional) ensure state for package. +# Defaults to 'present' +# # [*status_socket_path*] # (optional) Path to the driver status unix domain socket file. # Defaults to $::os_service_default @@ -57,6 +69,9 @@ # Defaults to $::os_service_default # class octavia::driver_agent ( + $manage_service = true, + $enabled = true, + $package_ensure = 'present', $status_socket_path = $::os_service_default, $stats_socket_path = $::os_service_default, $get_socket_path = $::os_service_default, @@ -69,11 +84,37 @@ class octavia::driver_agent ( $max_process_warning_percent = $::os_service_default, $provider_agent_shutdown_timeout = $::os_service_default, $enabled_provider_agents = $::os_service_default, -) inherits octavia::params { +) { include octavia::deps + include octavia::params - # Octavia packaging does not currently provide a separate agent service or package. + if $::octavia::params::driver_agent_package_name { + package { 'octavia-driver-agent': + ensure => $package_ensure, + name => $::octavia::params::driver_agent_package_name, + tag => ['openstack', 'octavia-package'], + } + } + + if $::octavia::params::driver_agent_service_name { + if $manage_service { + if $enabled { + $service_ensure = 'running' + } else { + $service_ensure = 'stopped' + } + + service { 'octavia-driver-agent': + ensure => $service_ensure, + name => $::octavia::params::driver_agent_service_name, + enable => $enabled, + hasstatus => true, + hasrestart => true, + tag => ['octavia-service'] + } + } + } octavia_config { 'driver_agent/status_socket_path': value => $status_socket_path; diff --git a/manifests/params.pp b/manifests/params.pp index 3cbae2e7..60bb6ecf 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -17,8 +17,10 @@ class octavia::params { $worker_package_name = 'openstack-octavia-worker' $health_manager_package_name = 'openstack-octavia-health-manager' $housekeeping_package_name = 'openstack-octavia-housekeeping' + $driver_agent_package_name = false $octavia_wsgi_script_path = '/var/www/cgi-bin/octavia' $octavia_wsgi_script_source = '/usr/bin/octavia-wsgi' + $driver_agent_service_name = false } 'Debian': { $common_package_name = 'octavia-common' @@ -26,8 +28,10 @@ class octavia::params { $worker_package_name = 'octavia-worker' $health_manager_package_name = 'octavia-health-manager' $housekeeping_package_name = 'octavia-housekeeping' + $driver_agent_package_name = 'octavia-driver-agent' $octavia_wsgi_script_path = '/usr/lib/cgi-bin/octavia' $octavia_wsgi_script_source = '/usr/bin/octavia-wsgi' + $driver_agent_service_name = 'octavia-driver-agent' } default: { fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \ diff --git a/releasenotes/notes/octavia-driver-agent-8b61e27e91e49b59.yaml b/releasenotes/notes/octavia-driver-agent-8b61e27e91e49b59.yaml new file mode 100644 index 00000000..b1551008 --- /dev/null +++ b/releasenotes/notes/octavia-driver-agent-8b61e27e91e49b59.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Now the ``octavia::driver_agent`` class can manage the package and + the service required to run the octavia-driver-agent service. diff --git a/spec/classes/octavia_driver_agent_spec.rb b/spec/classes/octavia_driver_agent_spec.rb index 415d215f..31fcece8 100644 --- a/spec/classes/octavia_driver_agent_spec.rb +++ b/spec/classes/octavia_driver_agent_spec.rb @@ -3,8 +3,7 @@ require 'spec_helper' describe 'octavia::driver_agent' do let :params do - { - } + {} end shared_examples_for 'octavia-driver-agent' do @@ -57,6 +56,24 @@ describe 'octavia::driver_agent' do end end + shared_examples_for 'octavia-driver-agent on Debian' do + context 'with default parameters' do + it { is_expected.to contain_package('octavia-driver-agent').with( + :ensure => 'present', + :name => 'octavia-driver-agent', + :tag => ['openstack', 'octavia-package'], + ) } + + it { is_expected.to contain_service('octavia-driver-agent').with( + :ensure => 'running', + :name => 'octavia-driver-agent', + :enable => true, + :hasstatus => true, + :hasrestart => true, + :tag => ['octavia-service'] + ) } + end + end on_supported_os({ :supported_os => OSDefaults.get_supported_os @@ -65,7 +82,11 @@ describe 'octavia::driver_agent' do let (:facts) do facts.merge!(OSDefaults.get_facts()) end + it_behaves_like 'octavia-driver-agent' + if facts[:osfamily] == 'Debian' + it_behaves_like 'octavia-driver-agent on Debian' + end end end