CORD-993
Eliminate elastic VM, install elasticstack on prod
remove old elastic VM config, install python-netaddr

Change-Id: I27f155733bc5c374e22cefec33086480ecb89df3
diff --git a/Vagrantfile b/Vagrantfile
index d4d4735..d7401ad 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -10,31 +10,6 @@
   end
   config.vm.synced_folder '.', '/vagrant', disabled: true
 
-  config.vm.define "elastic" do |d|
-    d.ssh.forward_agent = true
-    d.vm.box = "ubuntu/trusty64"
-    d.vm.synced_folder '.', '/vagrant', disabled: true
-
-    d.vm.network :forwarded_port, guest: 5601, host: 5601, host_ip: '*'
-    d.vm.network :forwarded_port, guest: 80, host: 9080, host_ip: '*'
-    d.vm.network :forwarded_port, guest: 9200, host: 9200, host_ip: '*'
-    d.vm.network :forwarded_port, guest: 5617, host: 5617, host_ip: '*', protocol: "udp"
-    d.vm.network :forwarded_port, guest: 2514, host: 2514, host_ip: '*'
-    d.vm.network :forwarded_port, guest: 4560, host: 4560, host_ip: '*'
-
-    d.vm.hostname = "elastic"
-    d.vm.network "private_network", ip: "10.100.198.222"
-    d.vm.provision :shell, path: "scripts/bootstrap_ansible.sh"
-    d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/elastic.yml -c local"
-    d.vm.provider "virtualbox" do |v|
-      v.memory = 4096
-    end
-    d.vm.provider :libvirt do |v, override|
-      v.memory = 4096
-      override.vm.synced_folder "..", "/cord", type: "nfs"
-    end
-  end
-
   config.vm.define "corddev" do |d|
     d.ssh.forward_agent = true
     d.vm.box = "ubuntu/trusty64"
@@ -73,6 +48,7 @@
         libvirt__dhcp_enabled: false
     d.vm.provision :shell, path: "scripts/bootstrap_ansible.sh"
     d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /cord/build/ansible/prod.yml -c local"
+    d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 cd /cord/build/platform-install; ansible-playbook -i inventory/head-localhost deploy-elasticstack-playbook.yml"
     d.vm.provider "virtualbox" do |v|
       v.memory = 2048
     end
diff --git a/ansible/elastic.yml b/ansible/elastic.yml
deleted file mode 100644
index 990bc5b..0000000
--- a/ansible/elastic.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-- hosts: localhost
-  remote_user: vagrant
-  serial: 1
-  roles:
-    - common
-    - java8-oracle
-    - install_elk
diff --git a/ansible/prod.yml b/ansible/prod.yml
index 73f08bc..cf7a678 100644
--- a/ansible/prod.yml
+++ b/ansible/prod.yml
@@ -1,5 +1,8 @@
+---
+
 - hosts: localhost
   remote_user: vagrant
   serial: 1
   roles:
+    - common
     - prod
diff --git a/ansible/roles/common/defaults/main.yml b/ansible/roles/common/defaults/main.yml
index add8842..4bc74b9 100644
--- a/ansible/roles/common/defaults/main.yml
+++ b/ansible/roles/common/defaults/main.yml
@@ -1,7 +1,6 @@
 hosts: [
   { host_ip: "10.100.198.200", host_name: "corddev"},
   { host_ip: "10.100.198.201", host_name: "prod"},
-  { host_ip: "10.100.198.222", host_name: "elastic"},
 ]
 
 use_latest_for:
diff --git a/ansible/roles/install_elk/files/10-udp-input.conf b/ansible/roles/install_elk/files/10-udp-input.conf
deleted file mode 100644
index d144f5b..0000000
--- a/ansible/roles/install_elk/files/10-udp-input.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-input {
-  udp {
-    port => 5617
-    codec => json
-  }
-}
diff --git a/ansible/roles/install_elk/files/11-log4j-input.conf b/ansible/roles/install_elk/files/11-log4j-input.conf
deleted file mode 100644
index 2d11577..0000000
--- a/ansible/roles/install_elk/files/11-log4j-input.conf
+++ /dev/null
@@ -1,15 +0,0 @@
-input {
-  log4j {
-    port => 4560
-    type => "log4j"
-  }
-}
-
-filter {
-  mutate {
-    rename => {"priority" => "level"}
-    rename => {"bundle.id" => "bundle_id"}
-    rename => {"bundle.name" => "bundle_name"}
-    rename => {"bundle.version" => "bundle_version"}
-  }
-}
diff --git a/ansible/roles/install_elk/files/12-syslog-input.conf b/ansible/roles/install_elk/files/12-syslog-input.conf
deleted file mode 100644
index d2331a8..0000000
--- a/ansible/roles/install_elk/files/12-syslog-input.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-input {
-  syslog {
-    port => 2514
-    type => "syslog"
-  }
-}
diff --git a/ansible/roles/install_elk/files/30-elasticsearch-output.conf b/ansible/roles/install_elk/files/30-elasticsearch-output.conf
deleted file mode 100644
index ab51625..0000000
--- a/ansible/roles/install_elk/files/30-elasticsearch-output.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-output {
-  elasticsearch { hosts => ["localhost:9200"] }
-  stdout { codec => rubydebug }
-}
diff --git a/ansible/roles/install_elk/tasks/main.yml b/ansible/roles/install_elk/tasks/main.yml
deleted file mode 100644
index 6948316..0000000
--- a/ansible/roles/install_elk/tasks/main.yml
+++ /dev/null
@@ -1,32 +0,0 @@
----
-# install_elk/tasks/main.yml
-
-- name: Add ELK repositories
-  apt_repository: repo={{ item }} state="present"
-  with_items:
-    - deb http://packages.elastic.co/elasticsearch/2.x/debian stable main
-    - deb http://packages.elastic.co/kibana/4.4/debian stable main
-    - deb http://packages.elastic.co/logstash/2.2/debian stable main
-
-- name: Install ELK
-  apt: name={{ item }} state=installed update_cache=yes force=yes
-  with_items:
-    - elasticsearch
-    - kibana
-    - logstash
-
-- name: Configure Logstash
-  copy: src={{ item }} dest=/etc/logstash/conf.d/{{ item }} owner=root group=root mode=0644
-  with_items:
-    - 10-udp-input.conf
-    - 11-log4j-input.conf
-    - 12-syslog-input.conf
-    - 30-elasticsearch-output.conf
-
-- name: Start ELK
-  service: name={{ item }} state=started enabled=yes
-  with_items:
-    - logstash
-    - elasticsearch
-    - kibana
-
diff --git a/scripts/bootstrap_ansible.sh b/scripts/bootstrap_ansible.sh
index ddaa522..6c7db5b 100755
--- a/scripts/bootstrap_ansible.sh
+++ b/scripts/bootstrap_ansible.sh
@@ -18,8 +18,8 @@
 set -e
 
 echo "Installing Ansible..."
-apt-get install -y software-properties-common
+apt-get install -y software-properties-common python-netaddr apt-transport-https 
 apt-add-repository ppa:ansible/ansible
 apt-get update
-apt-get install -y ansible apt-transport-https
+apt-get install -y ansible
 cp /cord/build/ansible/ansible.cfg /etc/ansible/ansible.cfg
diff --git a/scripts/cord-in-a-box.sh b/scripts/cord-in-a-box.sh
index 4ff7afe..17e3b65 100755
--- a/scripts/cord-in-a-box.sh
+++ b/scripts/cord-in-a-box.sh
@@ -150,17 +150,11 @@
 }
 
 function elk_up() {
-  cd $CORDDIR/build
-
-  sudo su $USER -c 'vagrant up elastic --provider libvirt'
-
-  # This is a workaround for a weird issue with ARP cache timeout breaking 'vagrant ssh'
-  # It allows SSH'ing to the machine via 'ssh corddev'
-  sudo su $USER -c "vagrant ssh-config elastic > $SSHCONFIG"
 
   cd $CORDDIR
   sudo chmod +x build/elk-logger/logstash_tail
-  build/elk-logger/logstash_tail --file install.out --hostport 10.100.198.222:5617 &
+
+  build/elk-logger/logstash_tail --file install.out --hostport 10.100.198.201:5617 &
 }
 
 function vagrant_vms_up() {
@@ -330,8 +324,8 @@
 
 bootstrap
 run_stage cloudlab_setup
-run_stage elk_up
 run_stage vagrant_vms_up
+run_stage elk_up
 
 if [[ $SETUP_ONLY -ne 0 ]]
 then