Merge "updating gradle build to match directory"
diff --git a/cord-head-playbook.yml b/cord-head-playbook.yml
index 7b9fac6..4774b88 100644
--- a/cord-head-playbook.yml
+++ b/cord-head-playbook.yml
@@ -53,3 +53,8 @@
   roles:
     - { role: automation-integration, when: on_maas }
 
+- name: Prologue
+  hosts: head
+  roles:
+    - head-prologue
+
diff --git a/roles/head-prologue/files/cord-http.conf b/roles/head-prologue/files/cord-http.conf
new file mode 100644
index 0000000..e3ba9d8
--- /dev/null
+++ b/roles/head-prologue/files/cord-http.conf
@@ -0,0 +1,49 @@
+<IfModule proxy_module>
+    ProxyPreserveHost on
+
+    # Map /fabric to the onos instance that is controlling the leaf
+    #     spine fabric
+    <Location /fabric/>
+        ProxyPass http://onos-fabric:8181/
+        ProxyPassReverse http://onos-fabric:8181/
+        ProxyPassReverseCookiePath  "/"  "/fabric/"
+        Header edit Location "(^http[s]?://[^/]*)(\.*)" "$1/fabric$2"
+    </Location>
+
+    <Location /fabric/onos/ui/websock/>
+        ProxyPass "ws://onos-fabric:8181/onos/ui/websock/" disablereuse=on
+    </Location>
+
+    # Map /vtn to the onos instance that is controller the cordvtn
+    #     application
+    <Location /vtn/>
+        ProxyPass http://onos-cord:8181/
+        ProxyPassReverse http://onos-cord:8181/
+        ProxyPassReverseCookiePath  "/"  "/vtn/"
+        Header edit Location "(^http[s]?://[^/]*)(\.*)" "$1/vtn$2"
+    </Location>
+
+    <Location /vtn/onos/ui/websock/>
+        ProxyPass "ws://onos-cord:8181/onos/ui/websock/" disablereuse=on
+    </Location>
+
+    # Map the various XOS roots to the XOS instance
+    ProxyPass /xos http://xos:80
+    ProxyPass /xos/ http://xos:80/
+    ProxyPass /api/ http://xos:80/api/
+    ProxyPass /admin/ http://xos:80/admin/
+    ProxyPass /static/ http://xos:80/static/
+    ProxyPass /loggedin/ http://xos:80/loggedin/
+    ProxyPass /serviceGrid/ http://xos:80/serviceGrid/
+
+</IfModule>
+
+<IfModule rewrite_module>
+    RewriteEngine On
+    # Redirect (permanently) requests for /MAAS to /MAAS/.
+    RewriteRule ^/MAAS$ %{REQUEST_URI}/ [R=301,L]
+</IfModule>
+
+# Redirects so that basic URLs entered go the right place
+Redirect /fabric /fabric/onos/ui
+Redirect /vtn /vtn/onos/ui
diff --git a/roles/head-prologue/handlers/main.yml b/roles/head-prologue/handlers/main.yml
new file mode 100644
index 0000000..f744763
--- /dev/null
+++ b/roles/head-prologue/handlers/main.yml
@@ -0,0 +1,7 @@
+---
+
+- name: reload apache2
+  become: yes
+  service:
+    name: apache2
+    state: reloaded
diff --git a/roles/head-prologue/tasks/main.yml b/roles/head-prologue/tasks/main.yml
new file mode 100644
index 0000000..a8b4f2b
--- /dev/null
+++ b/roles/head-prologue/tasks/main.yml
@@ -0,0 +1,35 @@
+---
+
+# If using a MAAS based POD deployment then copy over an apache configuration
+# that forwards to the various UIs
+- name: Ensure CORD Apache Configuration
+  become: yes
+  copy:
+    src: files/cord-http.conf
+    dest: /etc/apache2/conf-available/cord-http.conf
+    owner: root
+    group: root
+    mode: 0644
+  notify: reload apache2
+  when: on_maas
+
+- name: Ensure Modules
+  become: yes
+  command: a2enmod {{ item }}
+  register: mod_proxy
+  changed_when: mod_proxy.stdout.find('already enabled') == -1
+  notify: reload apache2
+  when: on_maas
+  with_items:
+    - proxy
+    - proxy_http
+    - proxy_wstunnel
+    - rewrite
+
+- name: Enable CORD Apache Configuration
+  become: yes
+  command: a2enconf cord-http
+  register: en_cord_http
+  changed_when: en_cord_http.stdout.find('already enabled') == -1
+  notify: reload apache2
+  when: on_maas