CORD-1175 Always rebuild all XOS containers

Change-Id: Ie06c54613710712e6e2f7878e70645475a8851cb
diff --git a/build.gradle b/build.gradle
index d198080..053fcc2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -31,6 +31,19 @@
             : 'candidate'
 }
 
+# Pull XOS images that exist on Docker Hub.
+# All images will get rebuilt during the buildImages step, but may at least
+# be able to use some intermediate images.
+task fetch(type: Exec) {
+  executable = "ansible-playbook"
+  args = [
+    "--extra-vars", "@../../build/genconfig/config.yml",
+    "--extra-vars", "build_docker_tag="+targetTag,
+    "--extra-vars", "cord_dir=../..",
+    "pull-xos-playbook.yml" ]
+}
+
+# Build all XOS images from source.
 task buildImages(type: Exec) {
   executable = "ansible-playbook"
   args = [
@@ -40,6 +53,7 @@
     "build-xos-playbook.yml" ]
 }
 
+# Publish XOS images to the head node registry.
 task publish(type: Exec) {
   executable = "ansible-playbook"
   args = [ "-i", "../../build/genconfig/cord-inv",
diff --git a/group_vars/all b/group_vars/all
index dedd5b2..047452d 100644
--- a/group_vars/all
+++ b/group_vars/all
@@ -15,7 +15,13 @@
     path: "{{ cord_dir }}/orchestration/xos/containers/xos"
     dockerfile: "Dockerfile.base"
     pull: True
+    build: False
     publish: False
+  - name: "xosproject/xos-postgres"
+    path: "{{ cord_dir }}/orchestration/xos/containers/postgresql"
+    dockerfile: "Dockerfile"
+    pull: True
+    publish: True
   - name: "xosproject/xos"
     path: "{{ cord_dir }}/orchestration/xos"
     dockerfile: "containers/xos/Dockerfile.xos"
diff --git a/roles/build-images/tasks/main.yml b/roles/build-images/tasks/main.yml
index 923af63..e737319 100644
--- a/roles/build-images/tasks/main.yml
+++ b/roles/build-images/tasks/main.yml
@@ -21,8 +21,10 @@
     tag: "{{ build_docker_tag }}"
     dockerfile: "{{ item.dockerfile }}"
     pull: False
-    force: "{{ item.rebuild | default(False) }}"
+    force: True
+    rm: False
   with_items: "{{ docker_images }}"
+  when: "{{ item.build | default(True) }}"
 
 - name: Build optional images
   docker_image:
@@ -31,7 +33,8 @@
     tag: "{{ build_docker_tag }}"
     dockerfile: "{{ item.dockerfile }}"
     pull: False
-    force: "{{ item.rebuild | default(False) }}"
+    force: True
+    rm: False
   with_items: "{{ docker_optional_images }}"
   when: build_optional_images
 
@@ -42,7 +45,8 @@
     path: "{{ cord_dir }}/{{ item.path }}"
     tag: "{{ build_docker_tag }}"
     pull: False
-    force: "{{ item.rebuild | default(False) }}"
+    force: True
+    rm: False
   with_items: "{{ enabled_gui_extensions }}"
 
 # Build synchronizer images
@@ -53,6 +57,7 @@
     dockerfile: "Dockerfile.synchronizer"
     tag: "{{ build_docker_tag }}"
     pull: False
-    force: "{{ item.rebuild | default(False) }}"
+    force: True
+    rm: False
   with_items: "{{ xos_services }}"
   when: not frontend_only and item.synchronizer is defined and item.synchronizer
diff --git a/roles/pull-images/tasks/main.yml b/roles/pull-images/tasks/main.yml
index 84d1c1f..4e9271d 100644
--- a/roles/pull-images/tasks/main.yml
+++ b/roles/pull-images/tasks/main.yml
@@ -5,4 +5,5 @@
   docker_image:
     name: "{{ item.name }}"
     repository: "{{ item.name }}:{{ build_docker_tag }}"
+    force: True
   with_items: "{{ docker_images | selectattr('pull') | list }}"