From f28deeed3cdb5b9dae4bec7b97142dc7d133c6a2 Mon Sep 17 00:00:00 2001
From: German Eichberger <German.eichberger@rackspace.com>
Date: Mon, 27 Mar 2017 18:16:49 -0400
Subject: [PATCH] Adds anti affinity hint and az configuration option

This adds the anti-affinity and availability zone configuration
options and recommends anti-affinity in the config documentation.

Change-Id: Ie4a196eba868b03b52bf98312c6a38b68369ad85
---
 defaults/main.yml                | 11 +++++++++++
 doc/source/configure-octavia.rst |  6 ++++--
 templates/octavia.conf.j2        |  4 ++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/defaults/main.yml b/defaults/main.yml
index 9f0f3e3b..b0eaf423 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -251,6 +251,17 @@ octavia_task_flow_max_workers: 5
 # your queue is crashing (Octavia will stream events to the neutron DB)
 octavia_event_streamer: True
 
+# this controls if Octavia should add an anti-affinity hint to make sure
+# two amphora are not placed pn the same host (the most common setup of
+# ant affinity features in Nova).
+# Since AIO only has one compute host this is set to false
+octavia_enable_anti_affinity: False
+
+# Some installations put hardware more suited for load balancing in special
+# availability zones. This allows to target a specific availability zone
+# for amphora creation
+#octavia_amp_availability_zone:
+
 octavia_hm_group: "octavia-health-manager"
 octavia_hm_hosts: "{% for host in groups[octavia_hm_group] %}{{ hostvars[host]['ansible_host'] }}{% if not loop.last %},{% endif %}{% endfor %}"
 
diff --git a/doc/source/configure-octavia.rst b/doc/source/configure-octavia.rst
index e1d5c17f..c5245276 100644
--- a/doc/source/configure-octavia.rst
+++ b/doc/source/configure-octavia.rst
@@ -171,8 +171,10 @@ Optional: Tuning Octavia for production use
 
 Please have a close look at the ``main.yml`` for tunable parameters.
 The most important change is to set Octavia into ACTIVE_STANDBY mode
-by adding ``octavia_loadbalancer_topology: ACTIVE_STANDBY`` to the
-user file in /etc/openstack-deploy
+by adding ``octavia_loadbalancer_topology: ACTIVE_STANDBY`` and
+``octavia_enable_anti_affinity=True`` to ensure that the active and passive
+amphora are (depending on the anti-affinity filter deployed in nova)  on two
+different hosts to the user file in /etc/openstack-deploy
 
 To speed up the creation of load balancers or in a SINGLE topolgy
 to speed up the failover a spare pool can be used.
diff --git a/templates/octavia.conf.j2 b/templates/octavia.conf.j2
index 2ecd1ced..f965e53e 100644
--- a/templates/octavia.conf.j2
+++ b/templates/octavia.conf.j2
@@ -321,6 +321,10 @@ endpoint_type = {{ octavia_clients_endpoint }}
 # insecure = False
 # ca_certificates_file =
 
+enable_anti_affinity = {{ octavia_enable_anti_affinity }}
+
+{% if octavia_amp_availability_zone is defined %}availability_zone={{ octavia_amp_availability_zone }}{%endif%}
+
 [glance]
 # The name of the glance service in the keystone catalog
 # service_name =