[CORD-2608]
Create scenarios suitable for kubespray and helm

Change-Id: I07b19cfc00165046f8fbe6807f2d8add28398cbd
diff --git a/ansible/roles/finish-kubespray/defaults/main.yml b/ansible/roles/finish-kubespray/defaults/main.yml
new file mode 100644
index 0000000..437d960
--- /dev/null
+++ b/ansible/roles/finish-kubespray/defaults/main.yml
@@ -0,0 +1,23 @@
+---
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+# finish-kubespray/defaults/main.yml
+
+kubespray_dir: "../kubespray"
+
+management_net_cidr: "10.1.0.0/24"
+
+head_vm_ip: "192.168.46.100"
+
diff --git a/ansible/roles/finish-kubespray/tasks/main.yml b/ansible/roles/finish-kubespray/tasks/main.yml
new file mode 100644
index 0000000..258c0ac
--- /dev/null
+++ b/ansible/roles/finish-kubespray/tasks/main.yml
@@ -0,0 +1,44 @@
+---
+# Copyright 2017-present Open Networking Foundation
+#
+# 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.
+
+# finish-kubespray/tasks/main.yml
+
+- name: Create ~/.kube directory
+  file:
+    state: directory
+    dest: "~/.kube"
+
+- name: Move kubespray admin.conf to ~/.kube/config
+  copy:
+    remote_src: true
+    src: "{{ kubespray_dir }}/artifacts/admin.conf"
+    dest: "~/.kube/config"
+
+- name: Find Vagrant head VM IP address
+  shell: "vagrant ssh-config | grep -m 1 HostName | awk '{print $2}'"
+  args:
+    chdir: "{{ config_cord_dir }}/build"
+  environment:
+    VAGRANT_CWD: "{{ config_cord_dir }}/build/scenarios/{{ cord_scenario }}"
+  register: vagrant_head_vm_ip
+  tags:
+    - skip_ansible_lint # there isn't a module for this, info retrieval
+
+- name: Fix config URL to match Vagrant head VM IP
+  lineinfile:
+    path: "~/.kube/config"
+    regexp: "^    server: https://{{ management_net_cidr | ipaddr(1) |  ipaddr('address') }}:6443"
+    line: "    server: https://{{ vagrant_head_vm_ip.stdout }}:6443"
+
diff --git a/ansible/roles/genconfig/templates/config.mk.j2 b/ansible/roles/genconfig/templates/config.mk.j2
index ecde390..1d3f916 100644
--- a/ansible/roles/genconfig/templates/config.mk.j2
+++ b/ansible/roles/genconfig/templates/config.mk.j2
@@ -73,6 +73,9 @@
 {% if docker_images_prereqs is defined %}
 DOCKER_IMAGES_PREREQS   = $(M)/{{ docker_images_prereqs | join(" $(M)/") }}
 {% endif %}
+{% if publish_docker_images_prereqs is defined %}
+PUBLISH_DOCKER_IMAGES_PREREQS = $(M)/{{ publish_docker_images_prereqs | join(" $(M)/") }}
+{% endif %}
 {% if start_xos_prereqs is defined %}
 START_XOS_PREREQS       = $(M)/{{ start_xos_prereqs | join(" $(M)/") }}
 {% endif %}
diff --git a/ansible/roles/prep-kubespray/defaults/main.yml b/ansible/roles/prep-kubespray/defaults/main.yml
index 6c8266d..7e3df07 100644
--- a/ansible/roles/prep-kubespray/defaults/main.yml
+++ b/ansible/roles/prep-kubespray/defaults/main.yml
@@ -18,3 +18,5 @@
 kubespray_version: "master"
 kubespray_dir: "../kubespray"
 
+management_net_cidr: "10.1.0.0/24"
+
diff --git a/ansible/roles/prep-kubespray/tasks/main.yml b/ansible/roles/prep-kubespray/tasks/main.yml
index 43a5128..6616ac4 100644
--- a/ansible/roles/prep-kubespray/tasks/main.yml
+++ b/ansible/roles/prep-kubespray/tasks/main.yml
@@ -26,5 +26,3 @@
     src: kubespray_inventory.j2
     dest: "{{ kubespray_dir }}/inventory/inventory.cord"
     mode: 0644
-
-
diff --git a/ansible/roles/prep-kubespray/templates/kubespray_inventory.j2 b/ansible/roles/prep-kubespray/templates/kubespray_inventory.j2
index bb70db4..6782bf2 100644
--- a/ansible/roles/prep-kubespray/templates/kubespray_inventory.j2
+++ b/ansible/roles/prep-kubespray/templates/kubespray_inventory.j2
@@ -1,28 +1,28 @@
-# created by prep-kubespray/templates/kubespray_inventory.j2
+# created by CORD ansible role: prep-kubespray/templates/kubespray_inventory.j2
 
-[kube-master]
+[cord-headnodes]
 {% for node in groups['head'] %}
-{{ node }}
-{% endfor %}
-{% for node in groups['compute'] %}
-{{ node }}
+{% set npi = ( physical_node_list | selectattr("name", "equalto", node) | first ) %}
+{{ node }} ip='{{ management_net_cidr | ipaddr(npi.ipv4_last_octet) |  ipaddr("address")  }}'
 {% endfor %}
 
-[etcd]
-{% for node in groups['head'] %}
-{{ node }}
-{% endfor %}
+[cord-computenodes]
 {% for node in groups['compute'] %}
-{{ node }}
+{% set npi = ( physical_node_list | selectattr("name", "equalto", node) | first ) %}
+{{ node }} ip='{{ management_net_cidr | ipaddr(npi.ipv4_last_octet) |  ipaddr("address")  }}'
 {% endfor %}
 
-[kube-node]
-{% for node in groups['head'] %}
-{{ node }}
-{% endfor %}
-{% for node in groups['compute'] %}
-{{ node }}
-{% endfor %}
+[kube-master:children]
+cord-headnodes
+cord-computenodes
+
+[etcd:children]
+cord-headnodes
+cord-computenodes
+
+[kube-node:children]
+cord-headnodes
+cord-computenodes
 
 [k8s-cluster:children]
 kube-node