From 24b824b15c90dd7fe032bccc869538602849b17c Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Thu, 3 Mar 2016 15:38:34 -0600 Subject: [PATCH] Add LBaaS v2 support This patch adds tasks to deploy the LBaaS v2 agent along with its related service and configuration files. Deployers can move between LBaaS v1 and v2 at any time. The tasks will ensure that the correct agent is running based on the deployer's neutron_plugins_base variable. Both agents could possibly run simultaneously for a short period of time, but that will be cleaned up by the tasks in neutron_lbaas.yml. This is a re-work of the changes proposed for OSA in change I1c9c43582c99ebd1fb7bacb6545bcad34a692880. Co-Authored-By: Bjoern Teipel Closes-bug: 1541130 Change-Id: I00b41634816a1f7f1dfb31fcc6f35050c8d223a4 --- defaults/main.yml | 19 ++++++++++++++++-- tasks/main.yml | 2 ++ tasks/neutron_check.yml | 23 ++++++++++++++++++++++ tasks/neutron_install.yml | 2 +- tasks/neutron_lbaas.yml | 35 ++++++++++++++++++++++++++++++++++ tasks/neutron_upstart_init.yml | 14 ++++++++++++++ templates/lbaas_agent.ini.j2 | 4 ++++ templates/neutron.conf.j2 | 4 ++++ 8 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 tasks/neutron_check.yml create mode 100644 tasks/neutron_lbaas.yml diff --git a/defaults/main.yml b/defaults/main.yml index 7f09dc99..30bbbf06 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -77,7 +77,7 @@ neutron_plugin_core: "{{ neutron_plugins[neutron_plugin_type].plugin_core }}" # neutron_plugin_base: # - neutron.services.l3_router.l3_router_plugin.L3RouterPlugin # - neutron.services.metering.metering_plugin.MeteringPlugin -# - neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPlugin +# - neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPluginv2 # - neutron.services.vpn.plugin.VPNDriverPlugin neutron_plugin_base: - neutron.services.l3_router.l3_router_plugin.L3RouterPlugin @@ -156,6 +156,16 @@ neutron_services: config_options: --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/lbaas_agent.ini config_overrides: "{{ neutron_lbaas_agent_ini_overrides }}" config_type: "ini" + neutron-lbaasv2-agent: + group: neutron_lbaas_agent + service_name: neutron-lbaasv2-agent + service_en: "{{ neutron_lbaasv2 }}" + service_conf: lbaas_agent.ini + service_group: neutron_agent + service_rootwrap: rootwrap.d/lbaas-haproxy.filters + config_options: --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/lbaas_agent.ini + config_overrides: "{{ neutron_lbaas_agent_ini_overrides }}" + config_type: "ini" neutron-server: group: neutron_server service_name: neutron-server @@ -164,8 +174,13 @@ neutron_services: config_options: "--config-file /etc/neutron/neutron.conf --config-file /etc/neutron/{{ neutron_plugins[neutron_plugin_type].plugin_ini }}" ## Neutron LBaaS -# Please add the LoadBalancerPlugin to the neutron_plugin_base list +# See documentation section titled "Configuring the Network Load Balacing +# Service (Optional)" for more details. +# +# To enable LBaaS v1, add LoadBalancerPlugin to neutron_plugin_base list. +# To enable LBaaS v2, add LoadBalancerPluginv2 to neutron_plugin_base list neutron_lbaas: "{% if 'neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPlugin' in neutron_plugin_base %}True{% else %}False{% endif %}" +neutron_lbaasv2: "{% if 'neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPluginv2' in neutron_plugin_base %}True{% else %}False{% endif %}" ## Neutron L3 ## Please add the L3RouterPlugin to the neutron_plugin_base list diff --git a/tasks/main.yml b/tasks/main.yml index 40646921..ad348083 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,10 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +- include: neutron_check.yml - include: neutron_pre_install.yml - include: neutron_install.yml - include: neutron_post_install.yml - include: neutron_upstart_init.yml +- include: neutron_lbaas.yml - include: neutron_db_setup.yml when: > diff --git a/tasks/neutron_check.yml b/tasks/neutron_check.yml new file mode 100644 index 00000000..4cf1068c --- /dev/null +++ b/tasks/neutron_check.yml @@ -0,0 +1,23 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Ensure LBaaS v1 and v2 are not enabled simultaneously + fail: + message: | + LBaaS v1 and v2 cannot be enabled at the same time. + Verify that your neutron_plugin_base variable is correct. + when: + - neutron_lbaas | bool + - neutron_lbaasv2 | bool diff --git a/tasks/neutron_install.yml b/tasks/neutron_install.yml index 5a34b709..1c458d6d 100644 --- a/tasks/neutron_install.yml +++ b/tasks/neutron_install.yml @@ -54,7 +54,7 @@ with_items: neutron_lbaas_apt_packages when: - inventory_hostname in groups[neutron_services['neutron-lbaas-agent']['group']] - - neutron_lbaas | bool + - neutron_lbaas | bool or neutron_lbaasv2 | bool tags: - neutron-install - neutron-apt-packages diff --git a/tasks/neutron_lbaas.yml b/tasks/neutron_lbaas.yml new file mode 100644 index 00000000..13e3e735 --- /dev/null +++ b/tasks/neutron_lbaas.yml @@ -0,0 +1,35 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# These tasks are here to handle a situation where a deployer has v1 deployed +# and then chooses to deploy v2 (or vice versa). The existing tasks within +# neutron_upstart_init.yml will deploy configuration files for both agents +# and both will be running on the system until these tasks run. +# +# These tasks will ensure that the correct agent is the only one running. + +- name: Ensure LBaaS v1 agent is stopped when v2 is in neutron_plugins_base + service: + name: neutron-lbaas-agent + enabled: no + state: stopped + when: neutron_lbaasv2 | bool + +- name: Ensure LBaaS v2 agent is stopped when v1 is in neutron_plugins_base + service: + name: neutron-lbaasv2-agent + enabled: no + state: stopped + when: neutron_lbaas | bool diff --git a/tasks/neutron_upstart_init.yml b/tasks/neutron_upstart_init.yml index ef47d726..75bfe93b 100644 --- a/tasks/neutron_upstart_init.yml +++ b/tasks/neutron_upstart_init.yml @@ -110,3 +110,17 @@ - neutron_services['neutron-lbaas-agent'].service_en | bool tags: - upstart-init + +- include: neutron_upstart_common_init.yml + vars: + program_name: "{{ neutron_services['neutron-lbaasv2-agent'].service_name }}" + program_config_options: "{{ neutron_services['neutron-lbaasv2-agent'].config_options }}" + service_name: "{{ neutron_service_name }}" + system_user: "{{ neutron_system_user_name }}" + system_group: "{{ neutron_system_group_name }}" + service_home: "{{ neutron_system_home_folder }}" + when: + - inventory_hostname in groups[neutron_services['neutron-lbaasv2-agent']['group']] + - neutron_services['neutron-lbaas-agent'].service_en | bool + tags: + - upstart-init diff --git a/templates/lbaas_agent.ini.j2 b/templates/lbaas_agent.ini.j2 index ff4e272d..38d7c6a7 100644 --- a/templates/lbaas_agent.ini.j2 +++ b/templates/lbaas_agent.ini.j2 @@ -27,7 +27,11 @@ interface_driver = {{ neutron_driver_interface }} # device_driver = path.to.provider1.driver.Driver # device_driver = path.to.provider2.driver.Driver # Default is: +{% if neutron_lbaas | bool %} device_driver = neutron_lbaas.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver +{% elif neutron_lbaasv2 | bool %} +device_driver = neutron_lbaas.drivers.haproxy.namespace_driver.HaproxyNSDriver +{% endif %} [haproxy] # Location to store config and state files diff --git a/templates/neutron.conf.j2 b/templates/neutron.conf.j2 index 44912f63..2bc2094b 100644 --- a/templates/neutron.conf.j2 +++ b/templates/neutron.conf.j2 @@ -157,7 +157,11 @@ pool_timeout = {{ neutron_db_pool_timeout }} # Service providers [service_providers] +{% if neutron_lbaas | bool %} service_provider = LOADBALANCER:Haproxy:neutron_lbaas.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default +{% elif neutron_lbaasv2 | bool %} +service_provider = LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default +{% endif %} #service_provider = VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default {% endif %}