CORD-1729 Support "localhost" as build node for full POD / CiaB

Change-Id: I2b30cbd7bbafd8c50b69878b60a5e4683afed9de
diff --git a/roles/docker-install/defaults/main.yml b/roles/docker-install/defaults/main.yml
index 964ba34..0cbe280 100644
--- a/roles/docker-install/defaults/main.yml
+++ b/roles/docker-install/defaults/main.yml
@@ -18,4 +18,4 @@
 # docker-install/defaults/main.yml
 
 docker_apt_repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
-
+docker_opts: ""
diff --git a/roles/docker-install/handlers/main.yml b/roles/docker-install/handlers/main.yml
new file mode 100644
index 0000000..e5c3c1c
--- /dev/null
+++ b/roles/docker-install/handlers/main.yml
@@ -0,0 +1,24 @@
+
+# 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.
+
+
+---
+# apache-proxy/handlers/main.yml
+
+- name: restart docker
+  become: yes
+  service:
+    name: docker
+    state: restarted
diff --git a/roles/docker-install/tasks/main.yml b/roles/docker-install/tasks/main.yml
index 965b127..ee8b9ea 100644
--- a/roles/docker-install/tasks/main.yml
+++ b/roles/docker-install/tasks/main.yml
@@ -46,6 +46,16 @@
     update_cache: yes
     cache_valid_time: 3600
 
+- name: Configure Docker
+  become: yes
+  template:
+      src=default_docker.j2
+      dest=/etc/default/docker
+      mode=0644
+      owner=root
+      group=root
+  notify: restart docker
+
 - name: Install docker-compose, docker python module, imagebuilder deps via pip
   become: yes
   pip:
diff --git a/roles/docker-install/templates/default_docker.j2 b/roles/docker-install/templates/default_docker.j2
new file mode 100644
index 0000000..dde0b36
--- /dev/null
+++ b/roles/docker-install/templates/default_docker.j2
@@ -0,0 +1,24 @@
+
+{#
+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.
+#}
+
+# Docker Upstart and SysVinit configuration file
+
+# Use DOCKER_OPTS to modify the daemon startup options.
+{% if docker_opts is defined %}
+DOCKER_OPTS="{{ docker_opts }}"
+{% endif %}
+
diff --git a/roles/imagebuilder-publish/tasks/main.yml b/roles/imagebuilder-publish/tasks/main.yml
index 1ddf28e..a31c938 100644
--- a/roles/imagebuilder-publish/tasks/main.yml
+++ b/roles/imagebuilder-publish/tasks/main.yml
@@ -19,11 +19,17 @@
   docker_image:
     name: "{{ deploy_docker_registry }}/{{ item.base }}:{{ deploy_docker_tag }}"
     state: absent
-  with_items: "{{ ib_built }} + {{ ib_pulled }}"
+  with_flattened:
+    - "{{ ib_built }}"
+    - "{{ ib_pulled }}"
+    - "{{ ib_preexisting_images }}"
 
 - name: Tag and push the images managed by ImageBuilder
   docker_image:
     name: "{{ item.base }}:{{ build_docker_tag }}"
     repository: "{{ deploy_docker_registry }}/{{ item.base }}:{{ deploy_docker_tag }}"
     push: True
-  with_items: "{{ ib_built }} + {{ ib_pulled }}"
+  with_flattened:
+    - "{{ ib_built }}"
+    - "{{ ib_pulled }}"
+    - "{{ ib_preexisting_images }}"