From a27e0740fa79e63030b8359347f4c723b29c1a40 Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Thu, 7 Sep 2017 20:44:05 +0100
Subject: [PATCH] Pass though host variables from kayobe to kolla-ansible
 inventory

By default this includes:

* ansible_host
* ansible_port
* ansible_ssh_private_key_file
---
 ansible/roles/kolla-ansible/defaults/main.yml              | 7 +++++++
 .../roles/kolla-ansible/templates/overcloud-top-level.j2   | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ansible/roles/kolla-ansible/defaults/main.yml b/ansible/roles/kolla-ansible/defaults/main.yml
index 8db76a07..0321ab6c 100644
--- a/ansible/roles/kolla-ansible/defaults/main.yml
+++ b/ansible/roles/kolla-ansible/defaults/main.yml
@@ -56,6 +56,13 @@ kolla_overcloud_inventory_top_level_group_map: {}
 # have no hosts mapped to them will be provided with an empty group definition.
 kolla_overcloud_inventory_kolla_top_level_groups: []
 
+# List of names of host variables to pass through from kayobe hosts to
+# kolla-ansible hosts, if set.
+kolla_overcloud_inventory_pass_through_host_vars:
+  - "ansible_host"
+  - "ansible_port"
+  - "ansible_ssh_private_key_file"
+
 ###############################################################################
 # Kolla-ansible global configuration options.
 
diff --git a/ansible/roles/kolla-ansible/templates/overcloud-top-level.j2 b/ansible/roles/kolla-ansible/templates/overcloud-top-level.j2
index 99e55f2a..0d213eb3 100644
--- a/ansible/roles/kolla-ansible/templates/overcloud-top-level.j2
+++ b/ansible/roles/kolla-ansible/templates/overcloud-top-level.j2
@@ -17,7 +17,7 @@
 # These hostnames must be resolvable from your deployment host
 {% for host in groups[group] %}
 {% set host_hv=hostvars[host] %}
-{{ host }}{% if "ansible_host" in host_hv %}    ansible_host={{ host_hv["ansible_host"] }}{% endif %}
+{{ host }}{% for hv_name in kolla_overcloud_inventory_pass_through_host_vars %}{% if hv_name in host_hv %} {{ hv_name }}={{ host_hv[hv_name] }}{% endif %}{% endfor %}
 
 {% endfor %}
 
-- 
GitLab