build the xos-base image and push to local repo

Change-Id: Ic606e9d8a04e9671ddfe3cf97a2dcb532c813b64
diff --git a/cord-head-playbook.yml b/cord-head-playbook.yml
index ce55372..8a821cf 100644
--- a/cord-head-playbook.yml
+++ b/cord-head-playbook.yml
@@ -42,6 +42,11 @@
     - { role: config-virt, become: yes }
     - create-vms
 
+- name: Create docker images
+  hosts: head
+  roles:
+    - xos-build
+
 - name: Set up VM's, juju, start ONOS and XOS
   hosts: head
   roles:
diff --git a/roles/xos-build/defaults/main.yml b/roles/xos-build/defaults/main.yml
new file mode 100644
index 0000000..3d67ba2
--- /dev/null
+++ b/roles/xos-build/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+
+xos_repo_dir: "{{ playbook_dir }}/../../orchestration/xos/containers/xos"
+docker_registry: "{{ inventory_hostname }}:5000"
diff --git a/roles/xos-build/tasks/main.yml b/roles/xos-build/tasks/main.yml
new file mode 100644
index 0000000..6bf54a0
--- /dev/null
+++ b/roles/xos-build/tasks/main.yml
@@ -0,0 +1,24 @@
+---
+# tasks for xos-build role
+
+- name: Check to see if orchestration/xos directory exists
+  local_action: stat path={{ xos_repo_dir }}
+  register: xosdir
+
+- name: build XOS base container image
+  local_action: shell cd {{ xos_repo_dir }} && make base
+  when:
+      xosdir.stat.exists == True
+
+- name: tag xos base container image
+  local_action: command docker tag xosproject/xos-base {{ docker_registry }}/xosproject/xos-base:candidate
+  when:
+      xosdir.stat.exists == True
+
+- name: publish XOS base container image to local repo
+  local_action: shell cd {{ xos_repo_dir }} && docker push {{ docker_registry }}/xosproject/xos-base:candidate
+  when:
+      xosdir.stat.exists == True
+
+
+