diff --git a/Ansible/all-in-one.yaml b/Ansible/all-in-one.yaml index f61918b9674c5cf22ac74566659a7334f1bb1d6a..fb0e13cfb43e8a3db58a1a8dc7a8caa42123ff11 100644 --- a/Ansible/all-in-one.yaml +++ b/Ansible/all-in-one.yaml @@ -16,11 +16,10 @@ - hosts: COUCHGROUP gather_facts: true - -- hosts: COUCHGROUP roles: - - role: openstack-run-script - #roles: + - role: openstack-proxy + - role: openstack-run-script + diff --git a/Ansible/cluster_setup.sh b/Ansible/cluster_setup.sh index 28522917c85c03eb1801539a4485e815f25aedce..cc1867f8555ffea7c1adcdbcb61b7aef87323215 100644 --- a/Ansible/cluster_setup.sh +++ b/Ansible/cluster_setup.sh @@ -1,9 +1,14 @@ #!/bin/bash echo "== Set variables ==" -export declare nodes=$1 -export declare -a nodes=($2) -export VERSION='3.0.0' + +declare var1= echo $1 + +"I was run:" > msg.txt +echo $1 >>msg.txt +export declare nodes=($1 $2) +#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 size=${#nodes[@]} diff --git a/Ansible/host_vars/mrc.yaml b/Ansible/host_vars/mrc.yaml index fa348d9f35883adcd2cf2707c7251b0d159b8ec0..8ffa8d695c199de91ac72ded482c1cb133b946d8 100644 --- a/Ansible/host_vars/mrc.yaml +++ b/Ansible/host_vars/mrc.yaml @@ -50,11 +50,11 @@ security_groups: #Instance instances: - - name: couchdb1 + - name: prueba4 volumes: 'volumedb1' - - name: couchdb2 + - name: prueba5 volumes: 'volumedb2' -instance_image: 34ce7ec8-50f2-4604-a38f-7d81d1c2041d #f8b79936-6616-4a22-b55d-0d0a1d27bceb +instance_image: 916cad7a-c545-48b2-b36c-d509ee63b3ce #f8b79936-6616-4a22-b55d-0d0a1d27bceb instance_key_name: testkey instance_flavor: uom.mse.1c4g \ No newline at end of file diff --git a/Ansible/install_couchdb.sh b/Ansible/install_couchdb.sh new file mode 100644 index 0000000000000000000000000000000000000000..807d7593086c7fe1599078803d42cd6721582161 --- /dev/null +++ b/Ansible/install_couchdb.sh @@ -0,0 +1,34 @@ +echo "====== getting ip ======" +NODENAME=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) +echo "nodename couchdb@{$NODENAME}" + +# Enabling Apache CouchDB repository. +sudo apt update && sudo apt install -y curl apt-transport-https gnupg +curl -L https://couchdb.apache.org/repo/bintray-pubkey.asc | sudo apt-key add - +echo "deb https://apache.bintray.com/couchdb-deb bionic main" | sudo tee -a /etc/apt/sources.list + +# Set the password variable. +echo "== setting password for couchdb ====" +COUCHDB_PASSWORD=admin + +# Bindaddress: 0.0.0.0 (does not bind to anything). +echo "== Setting up cluster variable for couch ==" +echo "couchdb couchdb/mode select clustered +couchdb couchdb/mode seen true +couchdb couchdb/nodename string couchdb@${NODENAME} +couchdb couchdb/nodename seen true +couchdb couchdb/cookie string elmo +couchdb couchdb/cookie seen true +couchdb couchdb/bindaddress string 0.0.0.0 +couchdb couchdb/bindaddress seen true +couchdb couchdb/adminpass password ${COUCHDB_PASSWORD} +couchdb couchdb/adminpass seen true +couchdb couchdb/adminpass_again password ${COUCHDB_PASSWORD} +couchdb couchdb/adminpass_again seen true" | sudo debconf-set-selections + + +# update cache +sudo apt update + +# Enter non-interactive mode instead of interactive mode here. +sudo DEBIAN_FRONTEND=noninteractive apt-get install -y couchdb diff --git a/Ansible/roles/openstack-proxy/tasks/main.yaml b/Ansible/roles/openstack-proxy/tasks/main.yaml new file mode 100644 index 0000000000000000000000000000000000000000..99c1c86ab19c52446bb5f4841d56bac0738b4006 --- /dev/null +++ b/Ansible/roles/openstack-proxy/tasks/main.yaml @@ -0,0 +1,16 @@ +- name: Insert/Update "proxy setting" in /etc/environment + become: yes + become_user: root + blockinfile: + path: /etc/environment + block: | + HTTP_PROXY=http://wwwproxy.unimelb.edu.au:8000/ + HTTPS_PROXY=http://wwwproxy.unimelb.edu.au:8000/ + http_proxy=http://wwwproxy.unimelb.edu.au:8000/ + https_proxy=http://wwwproxy.unimelb.edu.au:8000/ + no_proxy=localhost,127.0.0.1,localaddress,172.16.0.0/12,.melbourne.rc.nectar.org.au,.storage.unimelb.edu.au,.cloud.unimelb.edu.au + +- name: Reboot VM that might have lots of updates to apply + become: yes + reboot: + reboot_timeout: 3600 diff --git a/Ansible/roles/openstack-run-script/tasks/main.yaml b/Ansible/roles/openstack-run-script/tasks/main.yaml index 67cad0ad10afa4210c42f21c688d8fa1555de51b..dcea6783ecfe2eb349f8b54a4ffed75395ca4a1f 100644 --- a/Ansible/roles/openstack-run-script/tasks/main.yaml +++ b/Ansible/roles/openstack-run-script/tasks/main.yaml @@ -1,2 +1,18 @@ +- name: example copying file with owner and permissions + copy: + src: /home/alex/CCC/project/comp90024/Ansible/install_couchdb.sh + dest: /home/ubuntu/install_couchdb.sh + owner: ubuntu + group: ubuntu + mode: 0644 + +- name: change script permissions + 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: /home/alex/CCC/project/comp90024/Ansible/cluster_setup.sh COUCHGROUP[0] COUCHGROUP[1] \ No newline at end of file + script: sh /home/alex/CCC/project/comp90024/Ansible/cluster_setup.sh COUCHGROUP[0] COUCHGROUP[1] \ No newline at end of file