diff --git a/Ansible/all-in-one.yaml b/Ansible/all-in-one.yaml new file mode 100644 index 0000000000000000000000000000000000000000..718155a064974be56d5287f78209c364ae757e15 --- /dev/null +++ b/Ansible/all-in-one.yaml @@ -0,0 +1,39 @@ +- hosts: localhost + vars: + ansible_python_interpreter: /usr/bin/python3 + vars_files: + - host_vars/mrc.yaml + gather_facts: true + + roles: + - role: openstack-common + - role: openstack-images + - role: openstack-volume + - role: openstack-security-group + - role: openstack-instance + - role: openstack-IP + #- role: openstack-volume-snapshot + +- hosts: COUCHGROUP + gather_facts: true + +- hosts: COUCHGROUP[0] + roles: + - role: openstack-run-script + #roles: + + + +#- hosts: COUCHGROUP + + # tasks: + # - set_fact: + # nodes: '{{ os_instance.results | map(attribute='item.openstack.public_v4') | list}}' + + # - debug: var=nodes + + + # vars_files: + # - host_vars/couchdb.yaml + # gather_facts: true + diff --git a/Ansible/cluster_setup.sh b/Ansible/cluster_setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..39861918c255a8ebc716e8cb645a6ebf5a5e9abb --- /dev/null +++ b/Ansible/cluster_setup.sh @@ -0,0 +1,36 @@ +#!/bin/sh + + +# export declare -a nodes=(172.26.130.79 172.26.131.9) +export declare -a nodes=$1 +export masternode=`echo ${nodes} | cut -f1 -d' '` +export declare -a othernodes=`echo ${nodes[@]} | sed s/${masternode}//` +export size=${#nodes[@]} +export user='admin' +export pass='admin' +export cookie='alexis' +export VERSION='3.1.1' +#set up cluter p1 +for node in ${othernodes} +do + curl -XPOST "http://${user}:${pass}@${masternode}:5984/_cluster_setup" \ + --header "Content-Type: application/json"\ + --data "{\"action\": \"enable_cluster\", \"bind_address\":\"0.0.0.0\",\ + \"username\": \"${user}\", \"password\":\"${pass}\", \"port\": \"5984\",\ + \"remote_node\": \"${node}\", \"node_count\": \"$(echo ${nodes[@]} | wc -w)\",\ + \"remote_current_user\":\"${user}\", \"remote_current_password\":\"${pass}\"}" +done +#set up cluster p2 +for node in ${othernodes} +do + curl -XPOST "http://${user}:${pass}@${masternode}:5984/_cluster_setup"\ + --header "Content-Type: application/json"\ + --data "{\"action\": \"add_node\", \"host\":\"${node}\",\ + \"port\": \"5984\", \"username\": \"${user}\", \"password\":\"${pass}\"}" +done +#Avoid error msg +curl -XGET "http://${user}:${pass}@${masternode}:5984/" +curl -XPOST "http://${user}:${pass}@${masternode}:5984/_cluster_setup"\ + --header "Content-Type: application/json" --data "{\"action\": \"finish_cluster\"}" +#Checking congfiguration +for node in "${nodes[@]}"; do curl -X GET "http://${user}:${pass}@${node}:5984/_membership"; done diff --git a/Ansible/host_vars/couchdb.yaml b/Ansible/host_vars/couchdb.yaml index b2869192bc18e2a801699817f4c05e7675f23526..a8621cdb745b1394dc93a5db8d0cf5d9944fc866 100644 --- a/Ansible/host_vars/couchdb.yaml +++ b/Ansible/host_vars/couchdb.yaml @@ -1,9 +1,5 @@ -- hosts: mrc.db - vars: - database_user: 'admin' - database_password: 'admin' - cookie: 'alexis' - ansible_python_interpreter: /usr/bin/python3.8 - - roles: - - role: \ No newline at end of file +#-hosts: COUCHGROUP +vars: + database_user: 'admin' + database_password: 'admin' + cookie: 'alexis' \ No newline at end of file diff --git a/Ansible/host_vars/mrc.yaml b/Ansible/host_vars/mrc.yaml index 6be6d0899bc6aa7cd34b26f6a87cd4d19864d827..fa348d9f35883adcd2cf2707c7251b0d159b8ec0 100644 --- a/Ansible/host_vars/mrc.yaml +++ b/Ansible/host_vars/mrc.yaml @@ -3,9 +3,9 @@ availability_zone: melbourne-qh2-uom # Volume volumes: - - vol_name: volPrueba1 + - vol_name: volumedb1 vol_size: 10 - - vol_name: volPrueba2 + - vol_name: volumedb2 vol_size: 10 #Security group @@ -22,14 +22,39 @@ security_groups: port_range_min: 80 port_range_max: 80 remote_ip_prefix: 0.0.0.0/0 + - name: couch_4369 + description: "Ansible couch_4369" + protocol: tcp + port_range_min: 4369 + port_range_max: 4369 + remote_ip_prefix: 0.0.0.0/0 + - name: couch_5984 + description: "Ansible couch_5984" + protocol: tcp + port_range_min: 5984 + port_range_max: 5984 + remote_ip_prefix: 0.0.0.0/0 + - name: couch_9100to9200 + description: "Ansible couch_9100to9200" + protocol: tcp + port_range_min: 9100 + port_range_max: 9200 + remote_ip_prefix: 0.0.0.0/0 + - name: port443 + description: "Ansible port443" + protocol: tcp + port_range_min: 443 + port_range_max: 443 + remote_ip_prefix: 0.0.0.0/0 + #Instance instances: - - name: prueba1 - volumes: 'volPrueba1' - - name: prueba2 - volumes: 'volPrueba2' + - name: couchdb1 + volumes: 'volumedb1' + - name: couchdb2 + volumes: 'volumedb2' instance_image: 34ce7ec8-50f2-4604-a38f-7d81d1c2041d #f8b79936-6616-4a22-b55d-0d0a1d27bceb -instance_key_name: couchTestKey +instance_key_name: testkey instance_flavor: uom.mse.1c4g \ No newline at end of file diff --git a/Ansible/hosts b/Ansible/hosts new file mode 100644 index 0000000000000000000000000000000000000000..492c40b7dc3b7a31f5d6b55f12047c3c362da854 --- /dev/null +++ b/Ansible/hosts @@ -0,0 +1,8 @@ +[COUCHGROUP] + + +[COUCHGROUP:vars] +ansible_python_interpreter= /usr/bin/python3 +ansible_user=ubuntu +ansible_ssh_private_key_file=/home/alex/CCC/testkey.pem +ansible_ssh_common_args='-o StrictHostKeyChecking=no' \ No newline at end of file diff --git a/Ansible/mrc.yaml b/Ansible/mrc.yaml deleted file mode 100644 index c3616984b4a6c4c975440b018b9c9c1b93b81310..0000000000000000000000000000000000000000 --- a/Ansible/mrc.yaml +++ /dev/null @@ -1,15 +0,0 @@ -- hosts: localhost - vars: - ansible_python_interpreter: /usr/bin/python3.8 - vars_files: - - host_vars/mrc.yaml - gather_facts: true - - roles: - - role: openstack-common - - role: openstack-images - - role: openstack-volume - - role: openstack-security-group - - role: openstack-instance - - role: openstack-IP -# - role: openstack-volume-snapshot \ No newline at end of file diff --git a/Ansible/roles/openstack-couchdb/tasks/main.yml b/Ansible/roles/openstack-couchdb/tasks/main.yml deleted file mode 100644 index 78bafceb972d0973c176b82af12b25231a349278..0000000000000000000000000000000000000000 --- a/Ansible/roles/openstack-couchdb/tasks/main.yml +++ /dev/null @@ -1,13 +0,0 @@ -- name: Bind the clustered interface to all IP addresses availble on this machine - - command: curl -X PUT http://{{ database_user }}:{{ database_password }}@127.0.0.1:5984/_node/_local/_config/httpd/bind_address -d '"0.0.0.0"' - -- name: Set the UUID of the node to - - command: curl -X PUT http://{{ database_user }}:{{ database_password }}@127.0.0.1:5984/_node/_local/_config/couchdb/uuid -d '"{{ database_uuid }}"' - -- name: Set the shared http secret for cookie creation - - command: curl -X PUT http://{{ database_user }}:{{ database_password }}@127.0.0.1:5984/_node/_local/_config/couch_httpd_auth/secret -d '"{{ database_secret }}" - - - name: Setup cluster diff --git a/Ansible/roles/openstack-run-script/tasks/main.yaml b/Ansible/roles/openstack-run-script/tasks/main.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9cb705ca71ac973524c9f1924ae4cc376d6db165 --- /dev/null +++ b/Ansible/roles/openstack-run-script/tasks/main.yaml @@ -0,0 +1,2 @@ +- name: Run script cluster + ansible.builtin.script: /home/alex/CCC/project/comp90024/Ansible/cluster_setup.sh COUCHGROUP \ No newline at end of file diff --git a/Ansible/run-all-in-one.sh b/Ansible/run-all-in-one.sh new file mode 100644 index 0000000000000000000000000000000000000000..b545ff39aaa1d033a1e8e5ddd56212fb50ed8c62 --- /dev/null +++ b/Ansible/run-all-in-one.sh @@ -0,0 +1,3 @@ +. ./unimelb-comp90024-2021-grp-62-openrc.sh; ansible-playbook -i hosts all-in-one.yaml + +#. ./unimelb-comp90024-2021-grp-62-openrc.sh; ansible-playbook couchdb.yaml \ No newline at end of file diff --git a/Ansible/run-mrc.sh b/Ansible/run-mrc.sh deleted file mode 100644 index 17c9fc8b032f7321896b30ce8f9f4a212301d980..0000000000000000000000000000000000000000 --- a/Ansible/run-mrc.sh +++ /dev/null @@ -1,3 +0,0 @@ -. ./unimelb-comp90024-2021-grp-62-openrc.sh; ansible-playbook mrc.yaml - -#. ./unimelb-comp90024-2021-grp-62-openrc.sh; ansible-playbook couchdb.yaml \ No newline at end of file diff --git a/presentation.odp b/presentation.odp new file mode 100644 index 0000000000000000000000000000000000000000..43169c352da1378bb2de99bd9e58198b2a3b39bb Binary files /dev/null and b/presentation.odp differ