From 6e4b996b9c3acf4b3cd161f6c1d949b9f853338d Mon Sep 17 00:00:00 2001
From: alex <dariasrodrig@student.unimelb.edu.au>
Date: Fri, 28 May 2021 04:19:59 +1000
Subject: [PATCH] Cluster deployed

---
 Ansible/all-in-one.yaml                          |  7 +++++--
 Ansible/cluster_setup.sh                         | 16 ++++++----------
 Ansible/host_vars/mrc.yaml                       |  8 ++++++--
 .../openstack-run-script-cluster/tasks/main.yaml | 16 ++++++++++++++++
 .../tasks/main.yaml                              |  8 +++-----
 5 files changed, 36 insertions(+), 19 deletions(-)
 create mode 100644 Ansible/roles/openstack-run-script-cluster/tasks/main.yaml
 rename Ansible/roles/{openstack-run-script => openstack-run-script-installcdb}/tasks/main.yaml (58%)

diff --git a/Ansible/all-in-one.yaml b/Ansible/all-in-one.yaml
index fb0e13c..08a414a 100644
--- a/Ansible/all-in-one.yaml
+++ b/Ansible/all-in-one.yaml
@@ -18,9 +18,12 @@
   gather_facts: true
   roles:
       - role: openstack-proxy
-      - role: openstack-run-script
+      - role: openstack-run-script-installcdb
  
-
+- hosts: COUCHGROUP[0]
+  gather_facts: true
+  roles:
+      - role: openstack-run-script-cluster
     
 
 #- hosts: COUCHGROUP
diff --git a/Ansible/cluster_setup.sh b/Ansible/cluster_setup.sh
index cc1867f..2582013 100644
--- a/Ansible/cluster_setup.sh
+++ b/Ansible/cluster_setup.sh
@@ -1,22 +1,18 @@
-#!/bin/bash
+#!/usr/bin/env bash
+echo $1 >> IP.txt
 
-echo "== Set variables =="
-
-declare var1= echo $1
-
-"I was run:" > msg.txt
-echo $1 >>msg.txt 
 export declare nodes=($1 $2)
+echo $2 >> IP.txt 
 #export declare -a nodes=($2)
 #export VERSION='3.0.0'
 export masternode=`echo ${nodes} | cut -f1 -d' '`
-export declare othernodes=`echo ${nodes[@]} | sed s/${masternode}//`
+export declare othernodes=`echo ${no	des[@]} | sed s/${masternode}//`
 export size=${#nodes[@]}
 export user='admin'
 export pass='admin'
-export cookie='alexis'
 export VERSION='3.1.1'
-#set up cluter p1
+export cookie='alexis'
+
 
 
 for node in ${othernodes}
diff --git a/Ansible/host_vars/mrc.yaml b/Ansible/host_vars/mrc.yaml
index 8ffa8d6..7269ae7 100644
--- a/Ansible/host_vars/mrc.yaml
+++ b/Ansible/host_vars/mrc.yaml
@@ -4,9 +4,11 @@ availability_zone: melbourne-qh2-uom
 # Volume
 volumes:
   - vol_name: volumedb1
-    vol_size: 10
+    vol_size: 40
   - vol_name: volumedb2
-    vol_size: 10
+    vol_size: 40
+  # - vol_name: volumedb3
+  #   vol_size: 40
 
 #Security group
 security_groups:
@@ -54,6 +56,8 @@ instances:
     volumes: 'volumedb1'
   - name: prueba5
     volumes: 'volumedb2'
+  # - name: prueba6
+  #   volumes:  'volumedb3'
 
 instance_image: 916cad7a-c545-48b2-b36c-d509ee63b3ce #f8b79936-6616-4a22-b55d-0d0a1d27bceb
 instance_key_name: testkey
diff --git a/Ansible/roles/openstack-run-script-cluster/tasks/main.yaml b/Ansible/roles/openstack-run-script-cluster/tasks/main.yaml
new file mode 100644
index 0000000..2802a6b
--- /dev/null
+++ b/Ansible/roles/openstack-run-script-cluster/tasks/main.yaml
@@ -0,0 +1,16 @@
+- name: Copy couch db cluster setup script with owner and permissions
+  copy:
+    src: /home/alex/CCC/project/comp90024/Ansible/cluster_setup.sh
+    dest: /home/ubuntu/cluster_setup.sh
+    owner: ubuntu
+    group: ubuntu
+    mode: 0644
+
+- name: change script permissions
+  become: yes
+  shell: |
+    sudo chmod 777 /home/ubuntu/cluster_setup.sh
+
+- name: Run script cluster
+  become: yes
+  command: ./cluster_setup.sh {{ groups['COUCHGROUP'][0] }} {{ groups['COUCHGROUP'][1] }}
\ No newline at end of file
diff --git a/Ansible/roles/openstack-run-script/tasks/main.yaml b/Ansible/roles/openstack-run-script-installcdb/tasks/main.yaml
similarity index 58%
rename from Ansible/roles/openstack-run-script/tasks/main.yaml
rename to Ansible/roles/openstack-run-script-installcdb/tasks/main.yaml
index dcea678..d580628 100644
--- a/Ansible/roles/openstack-run-script/tasks/main.yaml
+++ b/Ansible/roles/openstack-run-script-installcdb/tasks/main.yaml
@@ -1,4 +1,4 @@
-- name: example copying file with owner and permissions
+- name: Copy couch db installation script with owner and permissions
   copy:
     src: /home/alex/CCC/project/comp90024/Ansible/install_couchdb.sh
     dest: /home/ubuntu/install_couchdb.sh
@@ -10,9 +10,7 @@
   become: yes
   shell: |
     sudo chmod 777 /home/ubuntu/install_couchdb.sh
+
 - name: install couchdb
   become: yes
-  command: sh /home/ubuntu/install_couchdb.sh
-
-- name: Run script cluster
-  script: sh /home/alex/CCC/project/comp90024/Ansible/cluster_setup.sh COUCHGROUP[0] COUCHGROUP[1]
\ No newline at end of file
+  command: sh /home/ubuntu/install_couchdb.sh
\ No newline at end of file
-- 
GitLab