Multiple updates. Converted many of the Yaml files from "dos" format to
"unix" format. Finalized the creation of the final installer file set
that can be copied to a USB Flash drive or other removable media.
Updated the config file with comments to make it more user friendly.
Deleted ansible files that were no longer needed. This update continues
to address the requirements laid out by Jira VOL-6.
Change-Id: I7434d2ec01768121e8d2ec50bb633c515281b37a
diff --git a/install/ansible/group_vars/all b/install/ansible/group_vars/all
index f00163a..dfa7529 100644
--- a/install/ansible/group_vars/all
+++ b/install/ansible/group_vars/all
@@ -1,15 +1,11 @@
-ip: "{{ facter_ipaddress_eth1 }}"
-consul_extra: ""
-proxy_url: http://{{ facter_ipaddress_eth1 }}
-proxy_url2: http://{{ facter_ipaddress_eth1 }}
-registry_url: 10.100.198.220:5000/
-jenkins_ip: 10.100.198.220
debian_version: xenial
docker_cfg: docker.cfg
docker_cfg_dest: /etc/default/docker
docker_registry: "localhost:5000"
docker_push_registry: "vinstall:5000"
cord_home: /home/volthainstall/cord
+target_voltha_dir: /cord/incubator/voltha
+target_voltha_home: /home/voltha
voltha_containers:
- voltha/nginx
- voltha/grafana
diff --git a/install/ansible/roles/apt-repository/tasks/debian.yml b/install/ansible/roles/apt-repository/tasks/debian.yml
deleted file mode 100644
index b77a9f6..0000000
--- a/install/ansible/roles/apt-repository/tasks/debian.yml
+++ /dev/null
@@ -1,45 +0,0 @@
-- name: The apt-repository is copied
- copy:
- src: "{{ cord_home }}/incubator/voltha/install/apt-mirror"
- dest: /home/vinstall
- owner: vinstall
- group: vinstall
- tags: [apt]
-- name: Nginx is installed
- apt:
- name: nginx
- state: latest
- tags: [apt]
-
-- name: Nginx config is copied
- copy:
- src: "{{ cord_home }}/incubator/voltha/install/nginx-default"
- dest: /etc/nginx/sites-enabled/default
- register: copy_result
- tags: [apt]
-
-- name: nginx is restarted
- command: service nginx restart
- when: copy_result|changed
- tags: [apt]
-
-#- name: NFS is installed TESTING ONLY REMOVE FOR PRODUCTION
-# apt:
-# name: nfs-common
-# state: latest
-# tags: [apt]
-#
-#- name: Apt repo is mounted TESTING ONLY REMOVE FOR PRODUCTION
-# mount:
-# name: /home/vinstall/apt-mirror
-# src: "{{ mount_host }}:{{ cord_home }}/incubator/voltha/install/apt-mirror"
-# fstype: nfs
-# state: mounted
-# tags: [apt]
-
-- name: Links to the repos are created
- file:
- src: /home/vinstall/apt-mirror/mirror/archive.ubuntu.com/ubuntu
- dest: /var/www/ubuntu
- state: link
- tags: [apt]
diff --git a/install/ansible/roles/apt-repository/tasks/main.yml b/install/ansible/roles/apt-repository/tasks/main.yml
deleted file mode 100644
index 1495847..0000000
--- a/install/ansible/roles/apt-repository/tasks/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-- include: debian.yml
- when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
-
-- include: centos.yml
- when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
diff --git a/install/ansible/roles/cluster-host/tasks/cluster-host.yml b/install/ansible/roles/cluster-host/tasks/cluster-host.yml
new file mode 100644
index 0000000..20dcd15
--- /dev/null
+++ b/install/ansible/roles/cluster-host/tasks/cluster-host.yml
@@ -0,0 +1,49 @@
+# 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: 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: [voltha]
+
+- name: Dependent software is installed
+ command: dpkg -i "{{ target_voltha_home }}/deb_files/{{ item }}"
+ with_items: "{{ deb_files }}"
+ when: target == "cluster"
+ ignore_errors: true
+ when: target == "cluster"
+ tags: [voltha]
+
+- name: Dependent software is initialized
+ command: apt-get -f install
+ when: target == "cluster"
+ tags: [voltha]
+
+- name: Python packages are installe
+ command: pip install {{ item }} --no-index --find-links "file://{{ target_voltha_home }}/{{ item }}"
+ with_items:
+ - docker-py
+ - netifaces
+ when: target == "cluster"
+ tags: [voltha]
+
+- name: Configuration directories are deleted
+ file:
+ path: "{{ target_voltha_home }}/{{ item }}"
+ state: absent
+ with_items:
+ - docker-py
+ - netifaces
+ - deb_files
+ when: target == "cluster"
+ tags: [voltha]
+
diff --git a/install/ansible/roles/cluster-host/tasks/main.yml b/install/ansible/roles/cluster-host/tasks/main.yml
new file mode 100644
index 0000000..41acd90
--- /dev/null
+++ b/install/ansible/roles/cluster-host/tasks/main.yml
@@ -0,0 +1,2 @@
+- include: cluster-host.yml
+ when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
diff --git a/install/ansible/roles/docker-registry/tasks/debian.yml b/install/ansible/roles/docker-registry/tasks/debian.yml
index 72903ab..788401f 100644
--- a/install/ansible/roles/docker-registry/tasks/debian.yml
+++ b/install/ansible/roles/docker-registry/tasks/debian.yml
@@ -1,5 +1,5 @@
-- name: The insecure docker registry is started
- command: docker run -d -p 5000:5000 --name registry registry:2
- register: result
- ignore_errors: true
- tags: [docker]
+- name: The insecure docker registry is started
+ command: docker run --restart=always -d -p 5000:5000 --name registry registry:2
+ register: result
+ ignore_errors: true
+ tags: [docker]
diff --git a/install/ansible/roles/docker/defaults/main.yml b/install/ansible/roles/docker/defaults/main.yml
index 338d16e..1c138f8 100644
--- a/install/ansible/roles/docker/defaults/main.yml
+++ b/install/ansible/roles/docker/defaults/main.yml
@@ -3,4 +3,4 @@
centos_files: [
{ src: "docker.centos.repo", dest: "/etc/yum.repos.d/docker.repo" },
{ src: "docker.centos.service", dest: "/lib/systemd/system/docker.service" },
-]
\ No newline at end of file
+]
diff --git a/install/ansible/roles/docker/tasks/debian.yml b/install/ansible/roles/docker/tasks/debian.yml
index 081fda9..8eed0ff 100644
--- a/install/ansible/roles/docker/tasks/debian.yml
+++ b/install/ansible/roles/docker/tasks/debian.yml
@@ -1,91 +1,64 @@
-- name: Debian add Docker repository and update apt cache
- apt_repository:
- repo: deb https://apt.dockerproject.org/repo ubuntu-{{ debian_version }} main
- update_cache: yes
- state: present
- when: target == "installer"
- tags: [docker]
-
-- name: Debian Docker is present
- apt:
- name: docker-engine
- state: latest
- force: yes
- when: target == "installer"
- tags: [docker]
-
-#- name: Docker deb install file is present
-# get_url:
-# url: https://apt.dockerproject.org/repo/pool/main/d/docker-engine/docker-engine_17.05.0~ce-0~ubuntu-xenial_amd64.deb
-# dest: /home/vinstall
-# owner: vinstall
-# group: vinstall
-# when: target == "installer"
-# tags: [docker]
-
-#- name: Docker dependencies satisfied
-# apt:
-# name: libltdl7
-# state: latest
-# force: yes
-# when: target == "cluster"
-# tags: [docker]
-
-#- name: Docker install deb file is copied
-# copy:
-# src: /home/vinstall/docker-engine_17.05.0~ce-0~ubuntu-xenial_amd64.deb
-# dest: /home/voltha
-# when: target == "cluster"
-# tags: [docker]
-
-#- name: Docker engine is installed
-# apt:
-# deb: /home/vinstall/docker-engine_17.05.0~ce-0~ubuntu-xenial_amd64.deb
-# when: target == "cluster"
-# tags: [docker]
-
-- name: Debian python-pip is present
- apt: name=python-pip state=present
- tags: [docker]
-
-- name: Debian docker-py is present
- pip:
- name: docker-py
- version: 1.6.0
- state: present
- when: target == "installer"
- tags: [docker]
-
-- name: netifaces pip package is present
- pip:
- name: netifaces
- version: 0.10.4
- state: present
- when: target == "installer"
- tags: [docker]
-
-- name: Debian files are present
- template:
- src: "{{ docker_cfg }}"
- dest: "{{ docker_cfg_dest }}"
- register: copy_result
- tags: [docker]
-
-- name: Debian Daemon is reloaded
- command: systemctl daemon-reload
- when: copy_result|changed and is_systemd is defined
- tags: [docker]
-
-- name: vagrant user is added to the docker group
- user:
- name: "{{ ansible_env['SUDO_USER'] }}"
- group: docker
- register: user_result
- tags: [docker]
-
-- name: Debian Docker service is restarted
- service:
- name: docker
- state: restarted
- when: copy_result|changed or user_result|changed
- tags: [docker]
+- name: Debian add Docker repository and update apt cache
+ apt_repository:
+ repo: deb https://apt.dockerproject.org/repo ubuntu-{{ debian_version }} main
+ update_cache: yes
+ state: present
+ when: target == "installer"
+ tags: [docker]
+
+- name: Debian Docker is present
+ apt:
+ name: docker-engine
+ state: latest
+ force: yes
+ when: target == "installer"
+ tags: [docker]
+
+- name: Debian python-pip is present
+ apt:
+ name: python-pip
+ state: present
+ when: target == "installer"
+ tags: [docker]
+
+- name: Debian docker-py is present
+ pip:
+ name: docker-py
+ version: 1.6.0
+ state: present
+ when: target == "installer"
+ tags: [docker]
+
+- name: netifaces pip package is present
+ pip:
+ name: netifaces
+ version: 0.10.4
+ state: present
+ when: target == "installer"
+ tags: [docker]
+
+- name: Docker config files are present
+ template:
+ src: "{{ docker_cfg }}"
+ dest: "{{ docker_cfg_dest }}"
+ register: copy_result
+ tags: [docker]
+
+- name: Debian Daemon is reloaded
+ command: systemctl daemon-reload
+ when: copy_result|changed and is_systemd is defined
+ tags: [docker]
+
+- name: vagrant user is added to the docker group
+ user:
+ name: "{{ ansible_env['SUDO_USER'] }}"
+ group: docker
+ register: user_result
+ tags: [docker]
+
+- name: Debian Docker service is restarted
+ service:
+ name: docker
+ state: restarted
+ when: copy_result|changed or user_result|changed
+ tags: [docker]
diff --git a/install/ansible/roles/installer/tasks/installer.yml b/install/ansible/roles/installer/tasks/installer.yml
index 5d29235..330d512 100644
--- a/install/ansible/roles/installer/tasks/installer.yml
+++ b/install/ansible/roles/installer/tasks/installer.yml
@@ -22,9 +22,10 @@
- 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
+ ignore_errors: true
- name: Test mode file is copied
copy:
src: "{{ cord_home }}/incubator/voltha/install/.test"
@@ -41,6 +42,11 @@
- 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]
diff --git a/install/ansible/roles/voltha/tasks/voltha.yml b/install/ansible/roles/voltha/tasks/voltha.yml
index c8cc78d..d6884e5 100644
--- a/install/ansible/roles/voltha/tasks/voltha.yml
+++ b/install/ansible/roles/voltha/tasks/voltha.yml
@@ -1,57 +1,93 @@
+# 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: /cord/incubator/voltha
+ 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: /cord/incubator/voltha
+ src: "/home/vinstall/{{ item }}"
+ dest: "{{ target_voltha_dir }}"
owner: voltha
group: voltha
with_items:
- compose
- nginx_config
- - docker-py
- - netifaces
- - deb_files
+ when: target == "cluster"
tags: [voltha]
- name: Nginx module symlink is present
file:
- dest: /cord/incubator/voltha/nginx_config/modules
+ 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: /cord/incubator/voltha/nginx_config/start_service.sh
+ path: "{{ target_voltha_dir }}/nginx_config/start_service.sh"
mode: 0755
- tags: [voltha]
-
-- name: Dependent software is installed
- command: dpkg -i /cord/incubator/voltha/deb_files/{{ item }}
- with_items: "{{ deb_files }}"
- when: target == "cluster"
- ignore_errors: true
- tags: [voltha]
-
-- name: Dependent software is initialized
- command: apt-get -f install
when: target == "cluster"
tags: [voltha]
-- name: Python packages are installe
- command: pip install {{ item }} --no-index --find-links file:///cord/incubator/voltha/{{ item }}
- with_items:
- - docker-py
- - netifaces
+- 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]
+- 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]
diff --git a/install/ansible/roles/voltha/templates/bash_profile.j2 b/install/ansible/roles/voltha/templates/bash_profile.j2
new file mode 100644
index 0000000..45cb87e
--- /dev/null
+++ b/install/ansible/roles/voltha/templates/bash_profile.j2
@@ -0,0 +1,3 @@
+if [ -f ~/.bashrc ]; then
+ . ~/.bashrc
+fi
diff --git a/install/ansible/roles/voltha/templates/bashrc.j2 b/install/ansible/roles/voltha/templates/bashrc.j2
new file mode 100644
index 0000000..73bcc88
--- /dev/null
+++ b/install/ansible/roles/voltha/templates/bashrc.j2
@@ -0,0 +1,2 @@
+DOCKER_HOST_IP={{ ansible_default_ipv4.address }}
+export DOCKER_HOST_IP
diff --git a/install/ansible/voltha.yml b/install/ansible/voltha.yml
index 2dbfaf1..f3a1cf4 100644
--- a/install/ansible/voltha.yml
+++ b/install/ansible/voltha.yml
@@ -5,8 +5,8 @@
target: cluster
roles:
- common
- - voltha
+ - cluster-host
- docker
- docker-compose
- - pull-images
+ - voltha
- java
diff --git a/install/ansible/volthainstall.yml b/install/ansible/volthainstall.yml
index 3e8c05a..b0629dd 100644
--- a/install/ansible/volthainstall.yml
+++ b/install/ansible/volthainstall.yml
@@ -9,9 +9,10 @@
- docker-compose
- installer
- docker-registry
-# - apt-repository
- hosts: voltha
remote_user: vagrant
serial: 1
+ vars:
+ target: installer
roles:
- - push-images
+ - voltha