From 3ed6170b5354233fedaae7b70314356b315096e9 Mon Sep 17 00:00:00 2001
From: alex <dariasrodrig@student.unimelb.edu.au>
Date: Fri, 28 May 2021 15:47:30 +1000
Subject: [PATCH] trials views

---
 Ansible/all-in-one.yaml                          |  2 ++
 Ansible/mapreduce.sh                             |  7 ++++---
 .../openstack-run-harvester/tasks/main.yaml      | 16 ++++++++++++++++
 .../openstack-run-script-cluster/tasks/main.yaml |  2 +-
 .../tasks/main.yaml                              |  2 +-
 .../roles/openstack-run-views/tasks/main.yaml    | 16 ++++++++++++++++
 Ansible/twt_harvest.sh                           | 10 ++++++++++
 7 files changed, 50 insertions(+), 5 deletions(-)
 create mode 100644 Ansible/roles/openstack-run-harvester/tasks/main.yaml
 create mode 100644 Ansible/roles/openstack-run-views/tasks/main.yaml
 create mode 100644 Ansible/twt_harvest.sh

diff --git a/Ansible/all-in-one.yaml b/Ansible/all-in-one.yaml
index 7f1f5db..ef813df 100644
--- a/Ansible/all-in-one.yaml
+++ b/Ansible/all-in-one.yaml
@@ -25,6 +25,8 @@
   gather_facts: true
   roles:
       - role: openstack-run-script-cluster
+      - role: openstack-run-harvester
+      - role: openstack-run-views
 
 - hosts: COUCHGROUP[1]
   gather_facts: true
diff --git a/Ansible/mapreduce.sh b/Ansible/mapreduce.sh
index 0518d90..770d969 100644
--- a/Ansible/mapreduce.sh
+++ b/Ansible/mapreduce.sh
@@ -1,5 +1,6 @@
 #!/usr/bin/env bash
 
-curl -X PUT http://172.26.130.79:5984/live_demo/_design/sports_by_city --data-binary @./sports_by_city.json
-curl -X PUT http://172.26.130.79:5984/live_demo/_design/retweets_followers --data-binary @./retweets_followers.json
-curl -X PUT http://172.26.130.79:5984/live_demo/_design/replies --data-binary @./retweets_followers.json
\ No newline at end of file
+
+curl -X PUT "http://$1:5984/live_demo2/_design/sports_by_city" --data-binary @./sports_by_city.json
+curl -X PUT "http://$1:5984/live_demo2/_design/retweets_followers" --data-binary @./retweets_followers.json
+curl -X PUT "http://$1:5984/live_demo2/_design/replies" --data-binary @./retweets_followers.json
\ No newline at end of file
diff --git a/Ansible/roles/openstack-run-harvester/tasks/main.yaml b/Ansible/roles/openstack-run-harvester/tasks/main.yaml
new file mode 100644
index 0000000..0bb9fe4
--- /dev/null
+++ b/Ansible/roles/openstack-run-harvester/tasks/main.yaml
@@ -0,0 +1,16 @@
+- name: Copy script for harvester
+  copy:
+    src: ./twt_harvest.sh
+    dest: /home/ubuntu/twt_harvest.sh
+    owner: ubuntu
+    group: ubuntu
+    mode: 0644
+
+- name: change script permissions
+  become: yes
+  shell: |
+    sudo chmod 777 /home/ubuntu/twt_harvest.sh
+
+- name: Run script cluster
+  become: yes
+  command: ./twt_harvest.sh
\ No newline at end of file
diff --git a/Ansible/roles/openstack-run-script-cluster/tasks/main.yaml b/Ansible/roles/openstack-run-script-cluster/tasks/main.yaml
index 2802a6b..9667d24 100644
--- a/Ansible/roles/openstack-run-script-cluster/tasks/main.yaml
+++ b/Ansible/roles/openstack-run-script-cluster/tasks/main.yaml
@@ -1,6 +1,6 @@
 - name: Copy couch db cluster setup script with owner and permissions
   copy:
-    src: /home/alex/CCC/project/comp90024/Ansible/cluster_setup.sh
+    src: ./cluster_setup.sh
     dest: /home/ubuntu/cluster_setup.sh
     owner: ubuntu
     group: ubuntu
diff --git a/Ansible/roles/openstack-run-script-installcdb/tasks/main.yaml b/Ansible/roles/openstack-run-script-installcdb/tasks/main.yaml
index d580628..369dabd 100644
--- a/Ansible/roles/openstack-run-script-installcdb/tasks/main.yaml
+++ b/Ansible/roles/openstack-run-script-installcdb/tasks/main.yaml
@@ -1,6 +1,6 @@
 - name: Copy couch db installation script with owner and permissions
   copy:
-    src: /home/alex/CCC/project/comp90024/Ansible/install_couchdb.sh
+    src: ./install_couchdb.sh
     dest: /home/ubuntu/install_couchdb.sh
     owner: ubuntu
     group: ubuntu
diff --git a/Ansible/roles/openstack-run-views/tasks/main.yaml b/Ansible/roles/openstack-run-views/tasks/main.yaml
new file mode 100644
index 0000000..6e9d62c
--- /dev/null
+++ b/Ansible/roles/openstack-run-views/tasks/main.yaml
@@ -0,0 +1,16 @@
+- name: Copy couchdb views script with owner and permissions
+  copy:
+    src: ./mapreduce.sh
+    dest: /home/ubuntu/mapreduce.sh
+    owner: ubuntu
+    group: ubuntu
+    mode: 0644
+
+- name: change script permissions
+  become: yes
+  shell: |
+    sudo chmod 777 /home/ubuntu/mapreduce.sh
+
+- name: install couchdb
+  become: yes
+  command: sh /home/ubuntu/mapreduce.sh {{ groups['COUCHGROUP'][0] }}
\ No newline at end of file
diff --git a/Ansible/twt_harvest.sh b/Ansible/twt_harvest.sh
new file mode 100644
index 0000000..d2ebeda
--- /dev/null
+++ b/Ansible/twt_harvest.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+array=$(cat IP.txt)
+export mainnode=`echo ${array} | cut -f1 -d' '`
+git clone https://gitlab.eng.unimelb.edu.au/framosmorale/comp90024.git
+apt install python3-pip -y
+pip3 install -r ./comp90024/Data\ collection/requirements.txt
+python3 ./comp90024/Data\ collection/streamFile_to_couch.py "$mainnode"
+python3 ./comp90024/Data\ collection/searchFile_to_couch.py.py "$mainnode"
+python3 ./comp90024/Data\ collection/tweet_gatherer_app.py stream 0 "$mainnode" & python3 ./comp90024/Data\ collection/tweet_gatherer_app.py search 1 "$mainnode" & python3 ./comp90024/Data\ collection/tweet_gatherer_app.py stream 2 "$mainnode" & python3 ./comp90024/Data\ collection/tweet_gatherer_app.py stream 3 "$mainnode" & python3 ./comp90024/Data\ collection/tweet_gatherer_app.py stream 4 "$mainnode" & 
-- 
GitLab