Added the required initialization to start the docker swarm cluster.
Converted yet more dos format files to unix format. Updated the
document on building voltha on a QEMU/KVM virtualization environment
using vagrant. Added a configuration file for the install vagrant to
eventually enable multiple users on a single compute node all able to
run independent voltha docker swarm clusters as VMs. More work is
required to finalize multi-user test mode which will be submitted in a
subsequent update.

This update continues to address Jira VOL-6

Change-Id: I88bc41aa6484877cb76ad38f8bab894f141cebdb
diff --git a/install/ansible/group_vars/all b/install/ansible/group_vars/all
index dfa7529..311ec96 100644
--- a/install/ansible/group_vars/all
+++ b/install/ansible/group_vars/all
@@ -5,6 +5,8 @@
 docker_push_registry: "vinstall:5000"
 cord_home: /home/volthainstall/cord
 target_voltha_dir: /cord/incubator/voltha
+docker_py_version: "1.7.0"
+netifaces_version: "0.10.4"
 target_voltha_home: /home/voltha
 voltha_containers:
   - voltha/nginx
diff --git a/install/ansible/roles/cluster-host/files/ssh_config b/install/ansible/roles/cluster-host/files/ssh_config
new file mode 100644
index 0000000..990a43d
--- /dev/null
+++ b/install/ansible/roles/cluster-host/files/ssh_config
@@ -0,0 +1,3 @@
+Host *
+   StrictHostKeyChecking no
+   UserKnownHostsFile=/dev/null
diff --git a/install/ansible/roles/cluster-host/tasks/cluster-host.yml b/install/ansible/roles/cluster-host/tasks/cluster-host.yml
index 20dcd15..20330c4 100644
--- a/install/ansible/roles/cluster-host/tasks/cluster-host.yml
+++ b/install/ansible/roles/cluster-host/tasks/cluster-host.yml
@@ -2,6 +2,39 @@
 # is running to install voltha in the cluster hosts.
 # Whe the target == "installer" the installer is being
 # created.
+- name: A .ssh directory for the voltha user exists
+  file:
+    #path: "{{ ansible_env['HOME'] }}/.ssh"
+    path: "/home/voltha/.ssh"
+    state: directory
+    owner: voltha
+    group: voltha
+  tags: [cluster_host]
+
+- name: known_hosts file is absent for the voltha user
+  file:
+    path: "/home/voltha/.ssh/known_hosts"
+    state: absent
+  tags: [cluster_host]
+
+- name: Known host checking is disabled
+  copy:
+    src: files/ssh_config
+    dest: "/home/voltha/.ssh/config"
+    owner: voltha
+    group: voltha
+    mode: 0600
+  tags: [cluster_host]
+
+- name: Cluster host keys are propagated to all hosts in the cluster
+  copy:
+    src: files/.keys
+    dest: "/home/voltha"
+    owner: voltha
+    group: voltha
+    mode: 0600
+  tags: [cluster_host]
+
 - name: Required configuration directories are copied
   copy:
     src: "/home/vinstall/{{ item }}"
@@ -13,7 +46,7 @@
     - netifaces
     - deb_files
   when: target == "cluster"
-  tags: [voltha]
+  tags: [cluster_host]
 
 - name: Dependent software is installed
   command: dpkg -i "{{ target_voltha_home }}/deb_files/{{ item }}"
@@ -21,20 +54,20 @@
   when: target == "cluster"
   ignore_errors: true
   when: target == "cluster"
-  tags: [voltha]
+  tags: [cluster_host]
 
 - name: Dependent software is initialized
   command: apt-get -f install
   when: target == "cluster"
-  tags: [voltha]
+  tags: [cluster_host]
 
-- name: Python packages are installe
+- name: Python packages are installed
   command: pip install {{ item }} --no-index --find-links "file://{{ target_voltha_home }}/{{ item }}"
   with_items:
     - docker-py
     - netifaces
   when: target == "cluster"
-  tags: [voltha]
+  tags: [cluster_host]
 
 - name: Configuration directories are deleted
   file:
@@ -45,5 +78,5 @@
     - netifaces
     - deb_files
   when: target == "cluster"
-  tags: [voltha]
+  tags: [cluster_host]
 
diff --git a/install/ansible/roles/common/tasks/main.yml b/install/ansible/roles/common/tasks/main.yml
index 8b1c054..c3bb649 100644
--- a/install/ansible/roles/common/tasks/main.yml
+++ b/install/ansible/roles/common/tasks/main.yml
@@ -2,6 +2,7 @@
   apt:
     name: jq
     force: yes
+  when: target != "cluster"
   tags: [common]
 
 - name: Host is present
diff --git a/install/ansible/roles/docker/tasks/debian.yml b/install/ansible/roles/docker/tasks/debian.yml
index 8eed0ff..d9f3f37 100644
--- a/install/ansible/roles/docker/tasks/debian.yml
+++ b/install/ansible/roles/docker/tasks/debian.yml
@@ -24,7 +24,7 @@
 - name: Debian docker-py is present
   pip:
     name: docker-py
-    version: 1.6.0
+    version: "{{ docker_py_version }}"
     state: present
   when: target == "installer"
   tags: [docker]
@@ -32,7 +32,7 @@
 - name: netifaces pip package is present
   pip:
     name: netifaces
-    version: 0.10.4
+    version: "{{ netifaces_version }}"
     state: present
   when: target == "installer"
   tags: [docker]
@@ -49,7 +49,7 @@
   when: copy_result|changed and is_systemd is defined
   tags: [docker]
 
-- name: vagrant user is added to the docker group
+- name: Sudo user is added to the docker group
   user:
     name: "{{ ansible_env['SUDO_USER'] }}"
     group: docker
diff --git a/install/ansible/roles/installer/tasks/installer.yml b/install/ansible/roles/installer/tasks/installer.yml
index 330d512..6be27ae 100644
--- a/install/ansible/roles/installer/tasks/installer.yml
+++ b/install/ansible/roles/installer/tasks/installer.yml
@@ -1,55 +1,55 @@
-- name: Ansible repository is available

-  apt_repository:

-    repo: 'ppa:ansible/ansible'

-  tags: [installer]

-- name: Debian ansible is present

-  apt:

-    name: ansible

-    state: latest

-    force: yes

-  tags: [installer]

-- name: Installer files and directories are copied

-  copy:

-    src: "{{ cord_home }}/incubator/voltha/{{ item }}"

-    dest: /home/vinstall

-    owner: vinstall

-    group: vinstall

-  with_items:

-    - install/installer.sh

-    - install/install.cfg

-    - install/ansible

-    - compose

-    - nginx_config

-  tags: [installer]

-- name: Determine if test mode is active

-  become: false

-  local_action: stat path="{{ cord_home }}/incubator/voltha/install/.test"

-  register: file

-  ignore_errors: true

-- name: Test mode file is copied

-  copy:

-    src: "{{ cord_home }}/incubator/voltha/install/.test"

-    dest: /home/vinstall

-  when: file.stat.exists

-- name: The installer is made executable

-  file:

-    path: /home/vinstall/installer.sh

-    mode: 0744

-  tags: [installer]

-- name: Python docker-py 1.6.0 package source is available

-  command: pip download -d /home/vinstall/docker-py "docker-py==1.6.0"

-  tags: [installer]

-- name: Python netifaces 0.10.4 package source is available

-  command: pip download -d /home/vinstall/netifaces "netifaces==0.10.4"

-  tags: [installer]

-- name: Deb file directory doesn't exist

-  file:

-    path: /home/vinstall/deb_files

-    state: absent

-  tags: [installer]

-- name: Deb files are saved.

-  command: cp -r /var/cache/apt/archives /home/vinstall

-  tags: [installer]

-- name: Deb file directory is renamed

-  command: mv /home/vinstall/archives /home/vinstall/deb_files

-  tags: [installer]

+- name: Ansible repository is available
+  apt_repository:
+    repo: 'ppa:ansible/ansible'
+  tags: [installer]
+- name: Debian ansible is present
+  apt:
+    name: ansible
+    state: latest
+    force: yes
+  tags: [installer]
+- name: Installer files and directories are copied
+  copy:
+    src: "{{ cord_home }}/incubator/voltha/{{ item }}"
+    dest: /home/vinstall
+    owner: vinstall
+    group: vinstall
+  with_items:
+    - install/installer.sh
+    - install/install.cfg
+    - install/ansible
+    - compose
+    - nginx_config
+  tags: [installer]
+- name: Determine if test mode is active
+  become: false
+  local_action: stat path="{{ cord_home }}/incubator/voltha/install/.test"
+  register: file
+  ignore_errors: true
+- name: Test mode file is copied
+  copy:
+    src: "{{ cord_home }}/incubator/voltha/install/.test"
+    dest: /home/vinstall
+  when: file.stat.exists
+- name: The installer is made executable
+  file:
+    path: /home/vinstall/installer.sh
+    mode: 0744
+  tags: [installer]
+- name: Python docker-py {{ docker_py_version }} package source is available
+  command: pip download -d /home/vinstall/docker-py "docker-py=={{ docker_py_version }}"
+  tags: [installer]
+- name: Python netifaces {{ netifaces_version }} package source is available
+  command: pip download -d /home/vinstall/netifaces "netifaces=={{ netifaces_version }}"
+  tags: [installer]
+- name: Deb file directory doesn't exist
+  file:
+    path: /home/vinstall/deb_files
+    state: absent
+  tags: [installer]
+- name: Deb files are saved.
+  command: cp -r /var/cache/apt/archives /home/vinstall
+  tags: [installer]
+- name: Deb file directory is renamed
+  command: mv /home/vinstall/archives /home/vinstall/deb_files
+  tags: [installer]
diff --git a/install/ansible/roles/swarm/tasks/main.yml b/install/ansible/roles/swarm/tasks/main.yml
new file mode 100644
index 0000000..92e73c2
--- /dev/null
+++ b/install/ansible/roles/swarm/tasks/main.yml
@@ -0,0 +1,2 @@
+- include: swarm.yml
+  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
diff --git a/install/ansible/roles/swarm/tasks/swarm.yml b/install/ansible/roles/swarm/tasks/swarm.yml
new file mode 100644
index 0000000..b0a7009
--- /dev/null
+++ b/install/ansible/roles/swarm/tasks/swarm.yml
@@ -0,0 +1,24 @@
+---
+- name: Ensure Swarm Master Initialization
+  command: "docker swarm init --advertise-addr {{ swarm_master_addr }}"
+  when: target == "swarm-master"
+  tags: [swarm]
+
+- name: Capture Swarm Cluster Manager Token
+  become: voltha
+  shell: ssh -i /home/voltha/.keys/{{ swarm_master_addr }} voltha@{{ swarm_master_addr }} sudo docker swarm join-token -q manager 2>/dev/null
+  register: manager_token
+  changed_when: false
+  when: target == "swarm-master-backup"
+  tags: [swarm]
+
+- name: Debug
+  debug:
+    msg: "TOKEN: {{ manager_token.stdout }}"
+  when: target == "swarm-master-backup"
+  tags: [swarm]
+
+- name: Join Swarm Cluster
+  command: "docker swarm join --token {{ manager_token.stdout }} {{ swarm_master_addr }}:2377"
+  when: target == "swarm-master-backup"
+  tags: [swarm]
diff --git a/install/ansible/swarm-master-backup.yml b/install/ansible/swarm-master-backup.yml
new file mode 100644
index 0000000..1e8eb3b
--- /dev/null
+++ b/install/ansible/swarm-master-backup.yml
@@ -0,0 +1,7 @@
+- hosts: swarm-master-backup
+  remote_user: voltha
+  serial: 1
+  vars:
+    target: swarm-master-backup
+  roles:
+    - swarm
diff --git a/install/ansible/swarm-master.yml b/install/ansible/swarm-master.yml
new file mode 100644
index 0000000..2c956d2
--- /dev/null
+++ b/install/ansible/swarm-master.yml
@@ -0,0 +1,7 @@
+- hosts: swarm-master
+  remote_user: voltha
+  serial: 1
+  vars:
+    target: swarm-master
+  roles:
+    - swarm