Initial commit of the voltha installer. There are several things that
need to be cleaned up but the installer is fully functional in test
mode and creates 3 non-clustered VMs with identical voltha installs
until such time as HA is ready. Once HA is ready, the scripts will be
modified to deploy the full HA cluster.
This update partially addresses Epic VOL-6.
Made changes requested by the reviewers.
Change-Id: I083239e1f349136d2ec1e51e09391da341177076
diff --git a/install/ansible/roles/docker/defaults/main.yml b/install/ansible/roles/docker/defaults/main.yml
new file mode 100644
index 0000000..338d16e
--- /dev/null
+++ b/install/ansible/roles/docker/defaults/main.yml
@@ -0,0 +1,6 @@
+docker_extra: ""
+
+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/files/docker.centos.repo b/install/ansible/roles/docker/files/docker.centos.repo
new file mode 100644
index 0000000..b472187
--- /dev/null
+++ b/install/ansible/roles/docker/files/docker.centos.repo
@@ -0,0 +1,6 @@
+[dockerrepo]
+name=Docker Repository
+baseurl=https://yum.dockerproject.org/repo/main/centos/7
+enabled=1
+gpgcheck=1
+gpgkey=https://yum.dockerproject.org/gpg
\ No newline at end of file
diff --git a/install/ansible/roles/docker/files/docker.centos.service b/install/ansible/roles/docker/files/docker.centos.service
new file mode 100644
index 0000000..3bbef84
--- /dev/null
+++ b/install/ansible/roles/docker/files/docker.centos.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=Docker Application Container Engine
+Documentation=https://docs.docker.com
+After=network.target docker.socket
+Requires=docker.socket
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/docker
+Type=notify
+ExecStart=/usr/bin/docker daemon --insecure-registry 10.100.198.200:5000 -H fd://
+MountFlags=slave
+LimitNOFILE=1048576
+LimitNPROC=1048576
+LimitCORE=infinity
+
+[Install]
+WantedBy=multi-user.target
diff --git a/install/ansible/roles/docker/tasks/centos.yml b/install/ansible/roles/docker/tasks/centos.yml
new file mode 100644
index 0000000..a8910d4
--- /dev/null
+++ b/install/ansible/roles/docker/tasks/centos.yml
@@ -0,0 +1,23 @@
+- name: CentOS files are copied
+ copy:
+ src: "{{ item.src }}"
+ dest: "{{ item.dest }}"
+ with_items: centos_files
+ tags: [docker]
+
+- name: CentOS package is installed
+ yum:
+ name: docker-engine
+ state: present
+ tags: [docker]
+
+- name: CentOS Daemon is reloaded
+ command: systemctl daemon-reload
+ tags: [docker]
+
+- name: CentOS service is running
+ service:
+ name: docker
+ state: running
+ tags: [docker]
+
diff --git a/install/ansible/roles/docker/tasks/debian.yml b/install/ansible/roles/docker/tasks/debian.yml
new file mode 100644
index 0000000..081fda9
--- /dev/null
+++ b/install/ansible/roles/docker/tasks/debian.yml
@@ -0,0 +1,91 @@
+- 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]
diff --git a/install/ansible/roles/docker/tasks/main.yml b/install/ansible/roles/docker/tasks/main.yml
new file mode 100644
index 0000000..1495847
--- /dev/null
+++ b/install/ansible/roles/docker/tasks/main.yml
@@ -0,0 +1,5 @@
+- 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/docker/templates/docker-swarm-master.service b/install/ansible/roles/docker/templates/docker-swarm-master.service
new file mode 100644
index 0000000..b284d4b
--- /dev/null
+++ b/install/ansible/roles/docker/templates/docker-swarm-master.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=Docker Application Container Engine
+Documentation=https://docs.docker.com
+After=network.target docker.socket
+Requires=docker.socket
+
+[Service]
+Type=notify
+ExecStart=/usr/bin/docker daemon -H fd:// \
+ --insecure-registry 10.100.198.220:5000 \
+ --registry-mirror=http://10.100.198.220:5001 \
+ --cluster-store=consul://{{ ip }}:8500/swarm \
+ --cluster-advertise={{ ip }}:2375 {{ docker_extra }}
+MountFlags=master
+LimitNOFILE=1048576
+LimitNPROC=1048576
+LimitCORE=infinity
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/install/ansible/roles/docker/templates/docker-swarm-node.service b/install/ansible/roles/docker/templates/docker-swarm-node.service
new file mode 100644
index 0000000..55bcc50
--- /dev/null
+++ b/install/ansible/roles/docker/templates/docker-swarm-node.service
@@ -0,0 +1,23 @@
+[Unit]
+Description=Docker Application Container Engine
+Documentation=https://docs.docker.com
+After=network.target docker.socket
+Requires=docker.socket
+
+[Service]
+Type=notify
+ExecStart=/usr/bin/docker daemon -H fd:// \
+ -H tcp://0.0.0.0:2375 \
+ -H unix:///var/run/docker.sock \
+ --insecure-registry 10.100.198.220:5000 \
+ --registry-mirror=http://10.100.198.220:5001 \
+ --cluster-store=consul://{{ ip }}:8500/swarm \
+ --cluster-advertise={{ ip }}:2375 {{ docker_extra }}
+MountFlags=slave
+LimitNOFILE=1048576
+LimitNPROC=1048576
+LimitCORE=infinity
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/install/ansible/roles/docker/templates/docker.cfg b/install/ansible/roles/docker/templates/docker.cfg
new file mode 100644
index 0000000..d59db12
--- /dev/null
+++ b/install/ansible/roles/docker/templates/docker.cfg
@@ -0,0 +1 @@
+DOCKER_OPTS="$DOCKER_OPTS --insecure-registry 192.168.121.91:5000 -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --registry-mirror=http://192.168.121.91:5001"