VOL-234. This update fixes issues seen with unresolved symbolic links
in the voltha tree when building and using the installer. There are
also updates to the documentation based on feedback receive from
multiple parties.

Change-Id: I21c7920cd52c42c7d5f4b48e064eafd04dd52203
diff --git a/install/ansible/roles/cluster-host/tasks/cluster-host.yml b/install/ansible/roles/cluster-host/tasks/cluster-host.yml
index b9b2146..d1648f5 100644
--- a/install/ansible/roles/cluster-host/tasks/cluster-host.yml
+++ b/install/ansible/roles/cluster-host/tasks/cluster-host.yml
@@ -35,18 +35,33 @@
     mode: 0600
   tags: [cluster_host]
 
+#- name: Required configuration directories are copied
+#  copy:
+#    src: "/home/vinstall/{{ item }}"
+#    dest: "{{ target_voltha_home }}"
+#    owner: voltha
+#    group: voltha
+#  with_items:
+#    - docker-py
+#    - netifaces
+#    - deb_files
+#  when: target == "cluster"
+#  tags: [cluster_host]
+
 - name: Required configuration directories are copied
-  copy:
+  synchronize:
     src: "/home/vinstall/{{ item }}"
     dest: "{{ target_voltha_home }}"
-    owner: voltha
-    group: voltha
+    archive: no
+    owner: no
+    perms: no
+    recursive: yes
+    links: yes
   with_items:
     - docker-py
     - netifaces
     - deb_files
-  when: target == "cluster"
-  tags: [cluster_host]
+  tags: [cluster-host]
 
 - name: apt lists are up-to-date
   copy:
diff --git a/install/ansible/roles/installer/tasks/installer.yml b/install/ansible/roles/installer/tasks/installer.yml
index 6be27ae..a958cb0 100644
--- a/install/ansible/roles/installer/tasks/installer.yml
+++ b/install/ansible/roles/installer/tasks/installer.yml
@@ -8,12 +8,28 @@
     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
+#    follow: no
+#  with_items:
+#    - install/installer.sh
+#    - install/install.cfg
+#    - install/ansible
+#    - compose
+#    - nginx_config
 - name: Installer files and directories are copied
-  copy:
+  synchronize:
     src: "{{ cord_home }}/incubator/voltha/{{ item }}"
     dest: /home/vinstall
-    owner: vinstall
-    group: vinstall
+    archive: no
+    owner: no
+    perms: no
+    recursive: yes
+    links: yes
   with_items:
     - install/installer.sh
     - install/install.cfg
@@ -21,6 +37,29 @@
     - 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:
+    - installer.sh
+    - install.cfg
+  tags: [installer]
+
 - name: Determine if test mode is active
   become: false
   local_action: stat path="{{ cord_home }}/incubator/voltha/install/.test"
diff --git a/install/ansible/roles/voltha/tasks/voltha.yml b/install/ansible/roles/voltha/tasks/voltha.yml
index e55a018..aa42aa1 100644
--- a/install/ansible/roles/voltha/tasks/voltha.yml
+++ b/install/ansible/roles/voltha/tasks/voltha.yml
@@ -1,170 +1,203 @@
-# Note: When the target == "cluster" the installer

-# is running to install voltha in the cluster hosts.

-# Whe the target == "installer" the installer is being

-# created.

-- name: The environment is properly set on login

-  template:

-    src: bashrc.j2

-    dest: "{{ target_voltha_home }}/.bashrc"

-    owner: voltha

-    group: voltha

-    mode: "u=rw,g=r,o=r"

-  when: target == "cluster"

-  tags: [voltha]

-  

-- name: The .bashrc file is executed on ssh login

-  template:

-    src: bash_profile.j2

-    dest: "{{ target_voltha_home }}/.bash_profile"

-    owner: voltha

-    group: voltha

-    mode: "u=rw,g=r,o=r"

-  when: target == "cluster"

-  tags: [voltha]

-  

-- name: Required directory exists

-  file:

-    path: "{{ target_voltha_dir }}"

-    state: directory

-    owner: voltha

-    group: voltha

-  when: target == "cluster"

-  tags: [voltha]

-

-- name: Required directories are copied

-  copy:

-    src: "/home/vinstall/{{ item }}"

-    dest: "{{ target_voltha_dir }}"

-    owner: voltha

-    group: voltha

-  with_items:

-    - compose

-    - nginx_config

-  when: target == "cluster"

-  tags: [voltha]

-

-- name: Nginx module symlink is present

-  file:

-    dest: "{{ target_voltha_dir }}/nginx_config/modules"

-    src: ../../usr/lib/nginx/modules

-    state: link

-    follow: no

-    force: yes

-  when: target == "cluster"

-  tags: [voltha]

-

-- name: Nginx statup script is executable

-  file:

-    path: "{{ target_voltha_dir }}/nginx_config/start_service.sh"

-    mode: 0755

-  when: target == "cluster"

-  tags: [voltha]

-

-- name: Configuration files are on the cluster host

-  copy:

-    src: "files/consul_config"

-    dest: "{{ target_voltha_dir }}"

-  when: target == "cluster"

-  tags: [voltha]

-

-- name: Docker containers for Voltha are pulled

-  command: docker pull {{ docker_registry }}/{{ item }}

-  with_items: "{{ voltha_containers }}"

-  when: target == "cluster"

-  tags: [voltha]

-- name: Docker images are re-tagged to expected names

-  command: docker tag {{ docker_registry }}/{{ item }} {{ item }}

-  with_items: "{{ voltha_containers }}"

-  when: target == "cluster"

-  tags: [voltha]

-#- name: Old docker image tags are removed

-#  command: docker rmi {{ docker_registry }}/{{ item }}

-#  with_items: "{{ voltha_containers }}"

-#  when: target == "cluster"

-#  tags: [voltha]

-

-

-# Update the insecure registry to reflect the current installer.

-# The installer name can change depending on whether test mode

-# is being used or not.

-- name: Enable insecure install registry

-  template:

-    src: "{{ docker_daemon_json }}"

-    dest: "{{ docker_daemon_json_dest }}"

-  register: copy_result

-  when: target == "installer"

-  tags: [voltha]

-

-- name: Debain Daemon is reloaded

-  command: systemctl daemon-reload

-  when: copy_result|changed and is_systemd is defined and target == "installer"

-  tags: [voltha]

-

-- name: Debian Docker service is restarted

-  service:

-    name: docker

-    state: restarted

-  when: copy_result|changed or user_result|changed

-  when: target == "installer"

-  tags: [voltha]

-

-- name: Docker images are re-tagged to registry for push

-  command: docker tag {{ item }} {{ docker_push_registry }}/{{ item }}

-  with_items: "{{ voltha_containers }}"

-  when: target == "installer"

-  tags: [voltha]

-- name: Docker containers for Voltha are pushed

-  command: docker push {{ docker_push_registry }}/{{ item }}

-  with_items: "{{ voltha_containers }}"

-  when: target == "installer"

-  tags: [voltha]

-- name: Temporary registry push tags are removed

-  command: docker rmi {{ docker_push_registry }}/{{ item }}

-  with_items: "{{ voltha_containers }}"

-  when: target == "installer"

-  tags: [voltha]

-

-- name: consul overlay network exists

-  command: docker network create --driver overlay --subnet 10.10.10.0/29 consul_net

-  when: target == "startup"

-  tags: [voltha]

-

-- name: kafka overlay network exists

-  command: docker network create --driver overlay --subnet 10.10.11.0/24 kafka_net

-  when: target == "startup"

-  tags: [voltha]

-

-- name: voltha overlay network exists

-  command: docker network create --driver overlay --subnet 10.10.12.0/24 voltha_net

-  when: target == "startup"

-  tags: [voltha]

-

-- name: consul cluster is running

-  command: docker service create --name consul --network consul_net --network voltha_net -e 'CONSUL_BIND_INTERFACE=eth0' --mode global --publish "8300:8300" --publish "8400:8400" --publish "8500:8500" --publish "8600:8600/udp" --mount type=bind,source=/cord/incubator/voltha/consul_config,destination=/consul/config consul agent -config-dir /consul/config

-  when: target == "startup"

-  tags: [voltha]

-

-- name: zookeeper node zk1 is running

-  command: docker service create --name zk1 --network kafka_net --network voltha_net -e 'ZOO_MY_ID=1' -e "ZOO_SERVERS=server.1=0.0.0.0:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888" zookeeper

-  when: target == "startup"

-  tags: [voltha]

-

-- name: zookeeper node zk2 is running

-  command: docker service create --name zk2 --network kafka_net --network voltha_net -e 'ZOO_MY_ID=2' -e "server.1=zk1:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zk3:2888:3888" zookeeper

-  when: target == "startup"

-  tags: [voltha]

-

-- name: zookeeper node zk3 is running

-  command: docker service create --name zk3 --network kafka_net --network voltha_net -e 'ZOO_MY_ID=3' -e "ZOO_SERVERS=server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=0.0.0.0:2888:3888" zookeeper

-  when: target == "startup"

-  tags: [voltha]

-

-- name: kafka is running

-  command: docker service create --name kafka --network voltha_net  -e "KAFKA_ADVERTISED_PORT=9092" -e "KAFKA_ZOOKEEPER_CONNECT=zk1:2181,zk2:2181,zk3:2181" -e "KAFKA_HEAP_OPTS=-Xmx256M -Xms128M" --mode global --publish "9092:9092" wurstmeister/kafka

-  when: target == "startup"

-  tags: [voltha]

-

-- name: voltha is running on a single host for testing

-  command: docker service create --name voltha_core --network voltha_net cord/voltha voltha/voltha/main.py -v --consul=consul:8500 --kafka=kafka

-  when: target == "startup"

-  tags: [voltha]

+# Note: When the target == "cluster" the installer
+# is running to install voltha in the cluster hosts.
+# Whe the target == "installer" the installer is being
+# created.
+- name: The environment is properly set on login
+  template:
+    src: bashrc.j2
+    dest: "{{ target_voltha_home }}/.bashrc"
+    owner: voltha
+    group: voltha
+    mode: "u=rw,g=r,o=r"
+  when: target == "cluster"
+  tags: [voltha]
+  
+- name: The .bashrc file is executed on ssh login
+  template:
+    src: bash_profile.j2
+    dest: "{{ target_voltha_home }}/.bash_profile"
+    owner: voltha
+    group: voltha
+    mode: "u=rw,g=r,o=r"
+  when: target == "cluster"
+  tags: [voltha]
+  
+- name: Required directory exists
+  file:
+    path: "{{ target_voltha_dir }}"
+    state: directory
+    owner: voltha
+    group: voltha
+  when: target == "cluster"
+  tags: [voltha]
+
+#- name: Required directories are copied
+#  copy:
+#    src: "/home/vinstall/{{ item }}"
+#    dest: "{{ target_voltha_dir }}"
+#    owner: voltha
+#    group: voltha
+#  with_items:
+#    - compose
+#    - nginx_config
+#  when: target == "cluster"
+#  tags: [voltha]
+
+- name: Installer files and directories are copied
+  synchronize:
+    src: "/home/vinstall/{{ item }}"
+    dest: "{{ target_voltha_dir }}"
+    archive: no
+    owner: no
+    perms: no
+    recursive: yes
+    links: yes
+  with_items:
+    - compose
+    - nginx_config
+  when: target == "cluster"
+  tags: [voltha]
+
+- name: Installer directories are owned by voltha
+  file:
+    path: /home/vinstall/{{ item }}
+    owner: voltha
+    group: voltha
+    recurse: yes
+    follow: no
+  with_items:
+    - compose
+    - nginx_config
+  when: target == "cluster"
+  tags: [voltha]
+
+#- name: Nginx module symlink is present
+#  file:
+#    dest: "{{ target_voltha_dir }}/nginx_config/modules"
+#    src: ../../usr/lib/nginx/modules
+#    state: link
+#    follow: no
+#    force: yes
+#  when: target == "cluster"
+#  tags: [voltha]
+
+- name: Nginx statup script is executable
+  file:
+    path: "{{ target_voltha_dir }}/nginx_config/start_service.sh"
+    mode: 0755
+  when: target == "cluster"
+  tags: [voltha]
+
+- name: Configuration files are on the cluster host
+  copy:
+    src: "files/consul_config"
+    dest: "{{ target_voltha_dir }}"
+  when: target == "cluster"
+  tags: [voltha]
+
+- name: Docker containers for Voltha are pulled
+  command: docker pull {{ docker_registry }}/{{ item }}
+  with_items: "{{ voltha_containers }}"
+  when: target == "cluster"
+  tags: [voltha]
+- name: Docker images are re-tagged to expected names
+  command: docker tag {{ docker_registry }}/{{ item }} {{ item }}
+  with_items: "{{ voltha_containers }}"
+  when: target == "cluster"
+  tags: [voltha]
+#- name: Old docker image tags are removed
+#  command: docker rmi {{ docker_registry }}/{{ item }}
+#  with_items: "{{ voltha_containers }}"
+#  when: target == "cluster"
+#  tags: [voltha]
+
+
+# Update the insecure registry to reflect the current installer.
+# The installer name can change depending on whether test mode
+# is being used or not.
+- name: Enable insecure install registry
+  template:
+    src: "{{ docker_daemon_json }}"
+    dest: "{{ docker_daemon_json_dest }}"
+  register: copy_result
+  when: target == "installer"
+  tags: [voltha]
+
+- name: Debain Daemon is reloaded
+  command: systemctl daemon-reload
+  when: copy_result|changed and is_systemd is defined and target == "installer"
+  tags: [voltha]
+
+- name: Debian Docker service is restarted
+  service:
+    name: docker
+    state: restarted
+  when: copy_result|changed or user_result|changed
+  when: target == "installer"
+  tags: [voltha]
+
+- name: TEMPORARY RULE TO INSTALL ZOOKEEPER
+  command: docker pull zookeeper
+  when: target == "installer"
+  tags: [voltha]
+
+- name: Docker images are re-tagged to registry for push
+  command: docker tag {{ item }} {{ docker_push_registry }}/{{ item }}
+  with_items: "{{ voltha_containers }}"
+  when: target == "installer"
+  tags: [voltha]
+- name: Docker containers for Voltha are pushed
+  command: docker push {{ docker_push_registry }}/{{ item }}
+  with_items: "{{ voltha_containers }}"
+  when: target == "installer"
+  tags: [voltha]
+- name: Temporary registry push tags are removed
+  command: docker rmi {{ docker_push_registry }}/{{ item }}
+  with_items: "{{ voltha_containers }}"
+  when: target == "installer"
+  tags: [voltha]
+
+- name: consul overlay network exists
+  command: docker network create --driver overlay --subnet 10.10.10.0/29 consul_net
+  when: target == "startup"
+  tags: [voltha]
+
+- name: kafka overlay network exists
+  command: docker network create --driver overlay --subnet 10.10.11.0/24 kafka_net
+  when: target == "startup"
+  tags: [voltha]
+
+- name: voltha overlay network exists
+  command: docker network create --driver overlay --subnet 10.10.12.0/24 voltha_net
+  when: target == "startup"
+  tags: [voltha]
+
+- name: consul cluster is running
+  command: docker service create --name consul --network consul_net --network voltha_net -e 'CONSUL_BIND_INTERFACE=eth0' --mode global --publish "8300:8300" --publish "8400:8400" --publish "8500:8500" --publish "8600:8600/udp" --mount type=bind,source=/cord/incubator/voltha/consul_config,destination=/consul/config consul agent -config-dir /consul/config
+  when: target == "startup"
+  tags: [voltha]
+
+- name: zookeeper node zk1 is running
+  command: docker service create --name zk1 --network kafka_net --network voltha_net -e 'ZOO_MY_ID=1' -e "ZOO_SERVERS=server.1=0.0.0.0:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888" zookeeper
+  when: target == "startup"
+  tags: [voltha]
+
+- name: zookeeper node zk2 is running
+  command: docker service create --name zk2 --network kafka_net --network voltha_net -e 'ZOO_MY_ID=2' -e "server.1=zk1:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zk3:2888:3888" zookeeper
+  when: target == "startup"
+  tags: [voltha]
+
+- name: zookeeper node zk3 is running
+  command: docker service create --name zk3 --network kafka_net --network voltha_net -e 'ZOO_MY_ID=3' -e "ZOO_SERVERS=server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=0.0.0.0:2888:3888" zookeeper
+  when: target == "startup"
+  tags: [voltha]
+
+- name: kafka is running
+  command: docker service create --name kafka --network voltha_net  -e "KAFKA_ADVERTISED_PORT=9092" -e "KAFKA_ZOOKEEPER_CONNECT=zk1:2181,zk2:2181,zk3:2181" -e "KAFKA_HEAP_OPTS=-Xmx256M -Xms128M" --mode global --publish "9092:9092" wurstmeister/kafka
+  when: target == "startup"
+  tags: [voltha]
+
+- name: voltha is running on a single host for testing
+  command: docker service create --name voltha_core --network voltha_net cord/voltha voltha/voltha/main.py -v --consul=consul:8500 --kafka=kafka
+  when: target == "startup"
+  tags: [voltha]