From cbc9ef78d66974cbe177e2ec911ebb111edba3d7 Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Fri, 3 Mar 2017 15:01:15 +0000
Subject: [PATCH] Support configuration of Kolla build sources

Adding a single non-default source for bifrost-base
---
 ansible/group_vars/all/kolla                    | 17 +++++++++++++++++
 ansible/roles/kolla-build/defaults/main.yml     | 10 ++++++++++
 .../kolla-build/templates/kolla-build.conf.j2   | 17 +++++++++++++++++
 ansible/roles/kolla/tasks/main.yml              |  6 ++++++
 .../{kolla-build.yml => seed-kolla-build.yml}   |  2 +-
 etc/kayobe/kolla.yml                            | 13 +++++++++++++
 6 files changed, 64 insertions(+), 1 deletion(-)
 rename ansible/{kolla-build.yml => seed-kolla-build.yml} (61%)

diff --git a/ansible/group_vars/all/kolla b/ansible/group_vars/all/kolla
index aea1572b..bb6355f3 100644
--- a/ansible/group_vars/all/kolla
+++ b/ansible/group_vars/all/kolla
@@ -40,6 +40,23 @@ kolla_docker_namespace: "kolla"
 # Kolla OpenStack release version. This should be a Docker image tag.
 kolla_openstack_release: "3.0.2"
 
+# Dict mapping names of sources to their definitions for
+# kolla_install_type=source. See kolla.common.config for details.
+# Example:
+# kolla_sources:
+#   ironic_base:
+#     type: git
+#     location: https://github.com/openstack/ironic
+#     reference: master
+kolla_sources:
+  bifrost-base:
+    type: "git"
+    location: "https://github.com/stackhpc/bifrost"
+    reference: "stackhpc-3.0.0"
+
+###############################################################################
+# Kolla-ansible configuration.
+
 # Whether TLS is enabled for the external API endpoints.
 kolla_enable_tls_external: "no"
 
diff --git a/ansible/roles/kolla-build/defaults/main.yml b/ansible/roles/kolla-build/defaults/main.yml
index 1fed3743..df2cf3e8 100644
--- a/ansible/roles/kolla-build/defaults/main.yml
+++ b/ansible/roles/kolla-build/defaults/main.yml
@@ -13,3 +13,13 @@ kolla_docker_namespace:
 
 # Valid option is Docker repository tag
 kolla_openstack_release:
+
+# Dict mapping names of sources to their definitions for
+# kolla_install_type=source. See kolla.common.config for details.
+# Example:
+# kolla_sources:
+#   ironic_base:
+#     type: git
+#     location: https://github.com/openstack/ironic
+#     reference: master
+kolla_sources: {}
diff --git a/ansible/roles/kolla-build/templates/kolla-build.conf.j2 b/ansible/roles/kolla-build/templates/kolla-build.conf.j2
index 01708836..74e2cfc9 100644
--- a/ansible/roles/kolla-build/templates/kolla-build.conf.j2
+++ b/ansible/roles/kolla-build/templates/kolla-build.conf.j2
@@ -16,3 +16,20 @@ tag={{ kolla_openstack_release }}
 
 # Path to a file containing template overrides.
 template_override={{ kolla_config_path }}/template-override.j2
+
+{% for source_name, source_def in kolla_sources.items() %}
+[{{ source_name }}]
+{% if source_def.type is defined %}
+# Type of source for {{ source_name }}.
+type = {{ source_def.type }}
+{% endif %}
+{% if source_def.location is defined %}
+# Location of source for {{ source_name }}.
+location = {{ source_def.location }}
+{% endif %}
+{% if source_def.reference is defined %}
+# Reference of source for {{ source_name }}.
+reference = {{ source_def.reference }}
+{% endif %}
+
+{% endfor %}
diff --git a/ansible/roles/kolla/tasks/main.yml b/ansible/roles/kolla/tasks/main.yml
index 81d14f1a..c6ddcf2d 100644
--- a/ansible/roles/kolla/tasks/main.yml
+++ b/ansible/roles/kolla/tasks/main.yml
@@ -21,6 +21,12 @@
   with_items:
     - { name: pip }
 
+- name: Ensure source code checkout path exists
+  file:
+    path: "{{ source_checkout_path }}"
+    state: directory
+    recurse: True
+
 - name: Ensure Kolla source code checkout exists
   git:
     repo: "{{ kolla_source_url }}"
diff --git a/ansible/kolla-build.yml b/ansible/seed-kolla-build.yml
similarity index 61%
rename from ansible/kolla-build.yml
rename to ansible/seed-kolla-build.yml
index 2953e268..715bcc12 100644
--- a/ansible/kolla-build.yml
+++ b/ansible/seed-kolla-build.yml
@@ -1,5 +1,5 @@
 ---
-- name: Ensure Kolla is configured
+- name: Ensure Kolla is configured on seed
   hosts: seed
   roles:
     - role: kolla
diff --git a/etc/kayobe/kolla.yml b/etc/kayobe/kolla.yml
index ff05d81e..c3a73d09 100644
--- a/etc/kayobe/kolla.yml
+++ b/etc/kayobe/kolla.yml
@@ -39,6 +39,19 @@
 # Kolla OpenStack release version. This should be a Docker image tag.
 #kolla_openstack_release:
 
+# Dict mapping names of sources to their definitions for
+# kolla_install_type=source. See kolla.common.config for details.
+# Example:
+# kolla_sources:
+#   ironic_base:
+#     type: git
+#     location: https://github.com/openstack/ironic
+#     reference: master
+#kolla_sources:
+
+###############################################################################
+# Kolla-ansible configuration.
+
 # Whether TLS is enabled for the external API endpoints.
 #kolla_enable_tls_external:
 
-- 
GitLab