Additional changes to remove privilaged command execution during the
installation proces. Also removed surplus file copies that are no longer
required.
A corner case where a vagrant VM isn't created before the installer is
run results in the vagrant-libvirt network not being defined or started.
Without this network the installer VM could not be started.

Change-Id: I2bd69a81b67c0f8149cd80abddce869675acba7d
diff --git a/install/CreateInstaller.sh b/install/CreateInstaller.sh
index 2003867..4a79b37 100755
--- a/install/CreateInstaller.sh
+++ b/install/CreateInstaller.sh
@@ -86,6 +86,29 @@
 	echo '"insecure-registries" : ["vinstall'${uId}':5000"]' >> ansible/roles/voltha/templates/daemon.json
 	echo '}' >> ansible/roles/voltha/templates/daemon.json
 
+	# Check to make sure that the vagrant-libvirt network is both defined and started
+	echo -e "${lBlue}Verify tha the ${lCyan}vagrant-libvirt${lBlue} network is defined and started${NC}"
+	virsh net-list | grep "vagrant-libvirt" > /dev/null
+	rtrn=$?
+	if [ $rtrn -eq 1 ]; then
+		# The network isn't running, check if it's defined
+		virsh net-list --all | grep "vagrant-libvirt" > /dev/null
+		rtrn=$?
+		if [ $rtrn -eq 1 ]; then
+			# Not defined either
+			echo -e "${lBlue}Defining the ${lCyan}vagrant-libvirt${lBlue} network${NC}"
+			virsh net-define vagrant-libvirt.xml
+			echo -e "${lBlue}Starting the ${lCyan}vagrant-libvirt${lBlue} network${NC}"
+			virsh net-start vagrant-libvirt
+		else
+			# Defined but not started
+			echo -e "${lBlue}Starting the ${lCyan}vagrant-libvirt${lBlue} network${NC}"
+			virsh net-start vagrant-libvirt
+		fi
+	else
+		echo -e "${lBlue}The ${lCyan}vagrant-libvirt${lBlue} network is ${green} running${NC}"
+	fi
+
 	# Change the installer name
 	iVmName="vInstaller${uId}"
 else
diff --git a/install/ansible/roles/cluster-host/tasks/main.yml b/install/ansible/roles/cluster-host/tasks/main.yml
index 3d2296e..8035072 100644
--- a/install/ansible/roles/cluster-host/tasks/main.yml
+++ b/install/ansible/roles/cluster-host/tasks/main.yml
@@ -64,11 +64,20 @@
   tags: [cluster-host]
 
 - name: apt lists are up-to-date
-  copy:
+  synchronize:
     src: "/var/lib/apt/lists"
-    dest: "/var/lib/apt"
+    dest: "/var/lib/apt/lists"
+    archive: no
+    owner: no
+    perms: no
+    rsync_opts:
+      - "--exclude=lock"
+      - "--exclude=partial"
+    recursive: yes
+    links: yes
   tags: [cluster_host]
 
+
 - name: Dependent software is installed (this can take about 10 Min, DONT'T PANIC, go for coffee instead)
   command: dpkg -R -i "{{ target_voltha_home }}/deb_files"
 #  ignore_errors: true
diff --git a/install/ansible/roles/installer/tasks/main.yml b/install/ansible/roles/installer/tasks/main.yml
index 57125df..dc6bbcf 100644
--- a/install/ansible/roles/installer/tasks/main.yml
+++ b/install/ansible/roles/installer/tasks/main.yml
@@ -31,38 +31,12 @@
     recursive: yes
     links: yes
   with_items:
-    - install/sort_packages.sh
-    - install/sort_packages.py
     - install/installer.sh
     - install/install.cfg
     - install/ansible
     - compose
     - nginx_config
   tags: [installer]
-- name: Installer directories are owned by vinstall
-  file:
-    path: /home/vinstall/{{ item }}
-    owner: vinstall
-    group: vinstall
-    recurse: yes
-    follow: no
-  with_items:
-    - ansible
-    - compose
-    - nginx_config
-  tags: [installer]
-- name: Installer files are owned by vinstall
-  file:
-    path: /home/vinstall/{{ item }}
-    owner: vinstall
-    group: vinstall
-    follow: no
-  with_items:
-    - sort_packages.sh
-    - sort_packages.py
-    - installer.sh
-    - install.cfg
-  tags: [installer]
 
 - name: Determine if test mode is active
   become: false
@@ -96,3 +70,30 @@
 - name: Deb file directory is renamed
   command: mv /home/vinstall/archives /home/vinstall/deb_files
   tags: [installer]
+- name: Installer directories are owned by vinstall
+  file:
+    path: /home/vinstall/{{ item }}
+    owner: vinstall
+    group: vinstall
+    recurse: yes
+    follow: no
+  with_items:
+    - ansible
+    - compose
+    - nginx_config
+    - .ansible
+    - deb_files
+    - docker-py
+    - netifaces
+  tags: [installer]
+- name: Installer files are owned by vinstall
+  file:
+    path: /home/vinstall/{{ item }}
+    owner: vinstall
+    group: vinstall
+    follow: no
+  with_items:
+    - installer.sh
+    - install.cfg
+    - docker-compose-Linux-x86_64
+  tags: [installer]
diff --git a/install/installer.sh b/install/installer.sh
index 4600efd..ae2310c 100755
--- a/install/installer.sh
+++ b/install/installer.sh
@@ -121,7 +121,7 @@
 # Running ansible
 echo -e "${lBlue}Running ansible${NC}"
 cp ansible/ansible.cfg .ansible.cfg
-sudo ansible-playbook ansible/voltha.yml -i ansible/hosts/cluster
+ansible-playbook ansible/voltha.yml -i ansible/hosts/cluster
 
 # Now all 3 servers need to be rebooted because of software installs.
 # Reboot them and wait patiently until they all come back.
@@ -175,7 +175,7 @@
                 echo  $i >> ansible/hosts/swarm-master-backup
         fi
 done
-sudo ansible-playbook ansible/swarm.yml -i ansible/hosts/swarm-master
-sudo ansible-playbook ansible/swarm.yml -i ansible/hosts/swarm-master-backup
-sudo ansible-playbook ansible/voltha.yml -i ansible/hosts/swarm-master
+ansible-playbook ansible/swarm.yml -i ansible/hosts/swarm-master
+ansible-playbook ansible/swarm.yml -i ansible/hosts/swarm-master-backup
+ansible-playbook ansible/voltha.yml -i ansible/hosts/swarm-master
 
diff --git a/install/vagrant-libvirt.xml b/install/vagrant-libvirt.xml
new file mode 100644
index 0000000..54c297c
--- /dev/null
+++ b/install/vagrant-libvirt.xml
@@ -0,0 +1,16 @@
+<network connections='3' ipv6='yes'>
+  <name>vagrant-libvirt</name>
+  <forward mode='nat'>
+    <nat>
+      <port start='1024' end='65535'/>
+    </nat>
+  </forward>
+  <bridge name='virbr1' stp='on' delay='0'/>
+  <mac address='52:54:00:50:19:43'/>
+  <ip address='192.168.121.1' netmask='255.255.255.0'>
+    <dhcp>
+      <range start='192.168.121.1' end='192.168.121.254'/>
+    </dhcp>
+  </ip>
+</network>
+