Ansible scripts for local cluster installation.
This change includes the following parts:
- Refactored aws scripts and share
the common part with non-aws cluster installation;
- Fixed aws_start.yml and aws_stop.yml to count
based on the user-provided tag.
Change-Id: I310f6f198c9ce41d7d7667dc4fbc21b3e34a77ab
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1525
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml b/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
index 48aa168..d0bd88a 100644
--- a/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
+++ b/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
@@ -52,6 +52,26 @@
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
+ <directory>src/main/opt/ansible/yaml</directory>
+ <outputDirectory>opt/aws/yaml</outputDirectory>
+ <includes>
+ <include>**/*.yml</include>
+ </includes>
+ <excludes>
+ <exclude>**/instance_start.yml</exclude>
+ <exclude>**/gen_conf.yml</exclude>
+ </excludes>
+ <filtered>true</filtered>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/opt/ansible/conf</directory>
+ <outputDirectory>opt/aws/conf</outputDirectory>
+ <includes>
+ <include>**/instance_settings.yml</include>
+ </includes>
+ <filtered>true</filtered>
+ </fileSet>
+ <fileSet>
<directory>target/appassembler/repo</directory>
<outputDirectory>repo</outputDirectory>
</fileSet>
diff --git a/asterixdb/asterix-server/src/main/opt/ansible/README b/asterixdb/asterix-server/src/main/opt/ansible/README
new file mode 100644
index 0000000..32e7999
--- /dev/null
+++ b/asterixdb/asterix-server/src/main/opt/ansible/README
@@ -0,0 +1,60 @@
+# ------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ------------------------------------------------------------
+
+To start cluster-based instance, you need to do the following steps:
+
+1. (Pre-requisite) Install Ansible, boto, and boto3:
+ ansible: pip install ansible
+ boto: pip install boto
+ boto3: pip install boto3
+ Make sure that the version of Ansible is no less than 2.2.1.0.
+
+2. Configure passwordless ssh from your current client that runs the scripts to
+ all nodes listed in conf/inventory.
+
+3. Edit the instance configuration file conf/cc.conf when necessary.
+ You can add/update whatever parameters in the [app] and [cc] sections.
+
+4. Edit the inventory file conf/inventory when necessary.
+ You mostly only need to sepecify the node DNS names (or IPs) for the cluster controller ([cc]) and node controllers
+ ([ncs]).
+
+ If the ssh user account for target machines is different from your current username, please uncomment
+ and edit the following two lines:
+ ;[all:vars]
+ ;ansible_ssh_user=<fill with your ssh account username>
+
+ If you want to specify advanced Ansible builtin variables, please refer to the following Ansible documentation:
+ http://docs.ansible.com/ansible/intro_inventory.html.
+
+5. Edit conf/instance_settings.yml to change the instance binary directories and commands when necessary.
+ By default, the binary directory will be under the home directory of the ssh user account on each node.
+
+6. Deploy the binary to all nodes:
+ bin/deploy.sh
+
+7. Launch your cluster instance:
+ bin/start.sh
+ Now you can use the cluster instance.
+
+8. If you want to stop the cluster instance, run the following script:
+ bin/stop.sh
+
+9. If you want to remove the binary on all nodes, run the following script:
+ bin/erase.sh
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/bin/deploy.sh
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/bin/deploy.sh
index e1bdc86..eff1ad0 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/bin/deploy.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
# ------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,19 +18,14 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+# Gets the absolute path so that the script can work no matter where it is invoked.
+pushd `dirname $0` > /dev/null
+SCRIPT_PATH=`pwd -P`
+popd > /dev/null
+ANSB_PATH=`dirname "${SCRIPT_PATH}"`
+
+INVENTORY=$ANSB_PATH/conf/inventory
+
+# Deploy the installation binary to all nodes.
+export ANSIBLE_HOST_KEY_CHECKING=false
+ansible-playbook -i $INVENTORY $ANSB_PATH/yaml/deploy_all.yml
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/bin/erase.sh
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/bin/erase.sh
index e1bdc86..e7bf19d 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/bin/erase.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
# ------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,19 +18,15 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+# Gets the absolute path so that the script can work no matter where it is invoked.
+pushd `dirname $0` > /dev/null
+SCRIPT_PATH=`pwd -P`
+popd > /dev/null
+ANSB_PATH=`dirname "${SCRIPT_PATH}"`
+
+INVENTORY=$ANSB_PATH/conf/inventory
+
+# Erase the installation binary on all nodes.
+# TODO(yingyi): erase all data/txn/log directories.
+export ANSIBLE_HOST_KEY_CHECKING=false
+ansible-playbook -i $INVENTORY $ANSB_PATH/yaml/erase_all.yml
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/bin/start.sh
old mode 100644
new mode 100755
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/bin/start.sh
index e1bdc86..55f5016
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/bin/start.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
# ------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,19 +18,14 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+# Gets the absolute path so that the script can work no matter where it is invoked.
+pushd `dirname $0` > /dev/null
+SCRIPT_PATH=`pwd -P`
+popd > /dev/null
+ANSB_PATH=`dirname "${SCRIPT_PATH}"`
+
+INVENTORY=$ANSB_PATH/conf/inventory
+
+# Start the cluster
+export ANSIBLE_HOST_KEY_CHECKING=false
+ansible-playbook -i $INVENTORY $ANSB_PATH/yaml/instance_start.yml
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/bin/stop.sh
old mode 100644
new mode 100755
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/bin/stop.sh
index e1bdc86..200d6e6
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/bin/stop.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
# ------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,19 +18,15 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+# Gets the absolute path so that the script can work no matter where it is invoked.
+pushd `dirname $0` > /dev/null
+SCRIPT_PATH=`pwd -P`
+popd > /dev/null
+ANSB_PATH=`dirname "${SCRIPT_PATH}"`
+
+INVENTORY=$ANSB_PATH/conf/inventory
+
+# Starts the cluster
+export ANSIBLE_HOST_KEY_CHECKING=false
+ansible-playbook -i $INVENTORY $ANSB_PATH/yaml/instance_stop.yml
+
diff --git a/asterixdb/asterix-server/src/main/opt/ansible/conf/cc.conf b/asterixdb/asterix-server/src/main/opt/ansible/conf/cc.conf
new file mode 100644
index 0000000..f5164ae
--- /dev/null
+++ b/asterixdb/asterix-server/src/main/opt/ansible/conf/cc.conf
@@ -0,0 +1,24 @@
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements. See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership. The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing,
+; software distributed under the License is distributed on an
+; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+; KIND, either express or implied. See the License for the
+; specific language governing permissions and limitations
+; under the License.
+
+[app]
+log.level=WARNING
+
+[nc]
+txnlogdir=txnlog
+iodevices=iodevice
+command=asterixnc
diff --git a/asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml b/asterixdb/asterix-server/src/main/opt/ansible/conf/instance_settings.yml
similarity index 97%
rename from asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml
rename to asterixdb/asterix-server/src/main/opt/ansible/conf/instance_settings.yml
index cc517b2..912fac8 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/conf/instance_settings.yml
@@ -30,7 +30,7 @@
ccbin: "asterixcc"
# The parent directory for the working directory.
-basedir: /home/ec2-user
+basedir: "{{ ansible_env.HOME }}"
# The working directory.
binarydir: "{{ basedir }}/{{ product }}"
diff --git a/asterixdb/asterix-server/src/main/opt/ansible/conf/inventory b/asterixdb/asterix-server/src/main/opt/ansible/conf/inventory
new file mode 100644
index 0000000..140ed43
--- /dev/null
+++ b/asterixdb/asterix-server/src/main/opt/ansible/conf/inventory
@@ -0,0 +1,27 @@
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements. See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership. The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing,
+; software distributed under the License is distributed on an
+; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+; KIND, either express or implied. See the License for the
+; specific language governing permissions and limitations
+; under the License.
+
+; Sets the ansible ssh user account if it is different from the current user
+; that runs the scripts.
+;[all:vars]
+;ansible_ssh_user=<fill with your ssh account username>
+
+[cc]
+localhost
+
+[ncs]
+localhost
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy.yml
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy.yml
index e1bdc86..ff06614 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy.yml
@@ -17,19 +17,13 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+- name: Deploy binaries
+ synchronize:
+ src: "{{ dist }}"
+ dest: "{{ binarydir }}"
+ archive: true
+
+- name: Ensure the log directory exists
+ file:
+ path: "{{ binarydir }}/logs"
+ state: directory
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy_all.yml
similarity index 66%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy_all.yml
index e1bdc86..09ff365 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/deploy_all.yml
@@ -17,19 +17,8 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
+- hosts: all
tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+ - include_vars: ../conf/instance_settings.yml
+
+ - include: deploy.yml
\ No newline at end of file
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/erase.yml
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/yaml/erase.yml
index e1bdc86..4ca4bcd 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/erase.yml
@@ -17,19 +17,7 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+- name: Remove the binary directory
+ file:
+ path: "{{ binarydir }}"
+ state: absent
\ No newline at end of file
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/erase_all.yml
similarity index 66%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/yaml/erase_all.yml
index e1bdc86..272fabe 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/erase_all.yml
@@ -17,19 +17,8 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
+- hosts: all
tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+ - include_vars: ../conf/instance_settings.yml
+
+ - include: erase.yml
\ No newline at end of file
diff --git a/asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/gen_conf.yml
similarity index 60%
copy from asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/yaml/gen_conf.yml
index cc517b2..f1be8a1 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/gen_conf.yml
@@ -17,29 +17,21 @@
# under the License.
# ------------------------------------------------------------
-# The name of the product (or extension) being used.
-product: asterixdb
-# The script that starts a nc service.
-ncsbin: "asterixncservice"
+- name: Ensure that the local temporary directory exists
+ file:
+ path: "{{ temp_dir }}"
+ state: directory
-# The script that starts a nc.
-ncbin: "asterixnc"
+- name: Generate the cluster configuration file
+ shell: cp "{{ playbook_dir }}/../conf/cc.conf" "{{ ccconf }}"
-# The script that starts a cc.
-ccbin: "asterixcc"
+- name: Populate NCs to the cluster configuration file
+ shell: printf "\n[nc/{{ node.0 + 1 }}]\naddress={{ node.1 }}\n" >> "{{ ccconf }}"
+ with_indexed_items: "{{ groups['ncs'] }}"
+ loop_control:
+ loop_var: node
-# The parent directory for the working directory.
-basedir: /home/ec2-user
+- name: Populate CC to the cluster configuration file "{{ ccconf }}"
+ shell: printf "\n[cc]\ncluster.address={{ groups['cc'][0] }}\n\n" >> "{{ ccconf }}"
-# The working directory.
-binarydir: "{{ basedir }}/{{ product }}"
-
-# The full binary distribution directory.
-dist: "../../../../"
-
-# The nc service command (script).
-ncservice: "{{ binarydir}}/bin/{{ ncsbin }}"
-
-# The cc service command (script).
-cc: "{{ binarydir}}/bin/{{ ccbin }}"
diff --git a/asterixdb/asterix-server/src/main/opt/ansible/yaml/instance_start.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/instance_start.yml
new file mode 100644
index 0000000..13de7cd
--- /dev/null
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/instance_start.yml
@@ -0,0 +1,52 @@
+# ------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ------------------------------------------------------------
+
+- hosts: [localhost,]
+ vars:
+ temp_dir: "/tmp/asterixdb"
+ inventory: "{{ temp_dir }}/inventory"
+ ccconf: "{{ temp_dir }}/cc.conf"
+ tasks:
+ - include: wait_ssh.yml
+
+ - include_vars: ../conf/instance_settings.yml
+
+ - include: gen_conf.yml
+
+- hosts: all
+ tasks:
+ - include_vars: ../conf/instance_settings.yml
+
+ - name: Ensure the log directory exists
+ file:
+ path: "{{ binarydir }}/logs"
+ state: directory
+
+- hosts: ncs
+ tasks:
+ - include_vars: ../conf/instance_settings.yml
+
+ - include: start_ncservice.yml
+
+- hosts: cc
+ tasks:
+ - include_vars: ../conf/instance_settings.yml
+
+ - include: start_cc.yml
+
diff --git a/asterixdb/asterix-server/src/main/opt/ansible/yaml/instance_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/instance_stop.yml
new file mode 100644
index 0000000..7a942e9
--- /dev/null
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/instance_stop.yml
@@ -0,0 +1,46 @@
+# ------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ------------------------------------------------------------
+
+- hosts: all
+ tasks:
+ - name: Check CC and NC processes
+ shell: jps | egrep '(CDriver|NCService)' | awk '{print $1}'
+ register: procs
+
+ - set_fact:
+ lines: "{{ procs.stdout_lines|length }}"
+
+ - name: Stop the CC and NCs
+ shell: kill `jps | egrep '(CDriver|NCService)' | awk '{print $1}'`
+ when: lines != "0"
+
+ - name: Wait two seconds
+ shell: sleep 2
+ when: lines != "0"
+
+ - name: Check leftover CC and NC processes
+ shell: jps | egrep '(CDriver|NCService)' | awk '{print $1}'
+ register: procs
+
+ - set_fact:
+ lines: "{{ procs.stdout_lines|length }}"
+
+ - name: Force stopping leftover CC and NC processes
+ shell: kill -9 `jps | egrep '(CDriver|NCService)' | awk '{print $1}'`
+ when: lines != "0"
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/start_cc.yml
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/yaml/start_cc.yml
index e1bdc86..32b1579 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/start_cc.yml
@@ -17,19 +17,17 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+- name: Copy cluster config to CC
+ synchronize:
+ src: /tmp/asterixdb/cc.conf
+ dest: "{{ basedir }}/cc.conf"
+
+- name: Update cluster config
+ shell: find -P "{{ basedir }}/cc.conf" | xargs perl -pi -e 's|command=asterixnc|command={{ ncbin }}|g'
+
+- name: Start CC
+ shell: nohup "{{ cc }}" -config-file "{{ basedir }}/cc.conf" &> "{{ binarydir }}/logs/cc.log" &
+ args:
+ chdir: "{{ binarydir }}"
+ async: 10
+ poll: 0
\ No newline at end of file
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/start_ncservice.yml
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/yaml/start_ncservice.yml
index e1bdc86..0f2f85d 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/start_ncservice.yml
@@ -17,19 +17,9 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+- name: Start NC Service
+ shell: nohup "{{ ncservice }}" &> "{{ binarydir }}/logs/ncservice.log" &
+ args:
+ chdir: "{{ binarydir }}"
+ async: 10
+ poll: 0
\ No newline at end of file
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/ansible/yaml/wait_ssh.yml
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/ansible/yaml/wait_ssh.yml
index e1bdc86..1e58cc7 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/ansible/yaml/wait_ssh.yml
@@ -17,19 +17,10 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+- name: Wait for SSH to come up at the cluster controller
+ wait_for: host="{{ item }}" port=22 search_regex=OpenSSH delay=0 timeout=300 state=started
+ with_items: "{{ groups['cc'] }}"
+
+- name: Wait for SSH to come up at node controllers
+ wait_for: host="{{ item }}" port=22 search_regex=OpenSSH delay=0 timeout=300 state=started
+ with_items: "{{ groups['ncs'] }}"
diff --git a/asterixdb/asterix-server/src/main/opt/aws/README b/asterixdb/asterix-server/src/main/opt/aws/README
index 52d503a..d267720 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/README
+++ b/asterixdb/asterix-server/src/main/opt/aws/README
@@ -19,21 +19,27 @@
To start an AWS cluster, you need to do the following steps:
-1. Create an AWS account and an IAM user.
+1. (Pre-requisite) Install Ansible, boto, and boto3:
+ ansible: pip install ansible
+ boto: pip install boto
+ boto3: pip install boto3
+ Make sure that the version of Ansible is no less than 2.2.1.0.
+
+2. Create an AWS account and an IAM user.
Set up a security group that you'd like to use for your AWS cluster. The security group should at least allow
all TCP connection from anywhere.
-2. Retrieve your AWS EC2 key pair name and fill that after "keypair:" in conf/aws_settings.yml;
+3. Retrieve your AWS EC2 key pair name and fill that after "keypair:" in conf/aws_settings.yml;
retrieve your AWS IAM "access key ID" and fill that after "access_key_id:" in conf/aws_settings.yml;
retrieve your AWS IAM "secret access key" and fill that after "secret_access_key:" in conf/aws_settings.yml.
Note that you can only read or download "access key ID" and "secret access key" once from your AWS console.
If you forget them, you have to create new keys again and delete the old ones.
-3. Customize other settings in conf/aws_settings.yml and conf/instance_settings.yml to whatever you want.
+4. Customize other settings in conf/aws_settings.yml and conf/instance_settings.yml to whatever you want.
Note that you have to make sure that the security group name (e.g., "group: default") matches the one you setup
in step 1.
-4. Configure your ssh setting by editing ~/.ssh/config and adding the following entry:
+5. Configure your ssh setting by editing ~/.ssh/config and adding the following entry:
Host *.amazonaws.com
IdentityFile <path_of_private_key>
Note that <path_of_private_key> should be replaced by the path to the file that stores the private key for the key
@@ -41,12 +47,6 @@
Host *.amazonaws.com
IdentityFile ~/.ssh/id_rsa
-5. Install ansible, boto, and boto3:
- ansible: pip install ansible
- boto: pip install boto
- boto3: pip install boto3
- Make sure that the version of ansible is no less than 2.2.1.0.
-
6. Launch your cluster instance on AWS:
bin/start.sh
Now you can use the AWS-based instance.
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/instance_start.yml b/asterixdb/asterix-server/src/main/opt/aws/ansible/instance_start.yml
deleted file mode 100644
index e71066c..0000000
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/instance_start.yml
+++ /dev/null
@@ -1,73 +0,0 @@
-# ------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# ------------------------------------------------------------
-
-- hosts: all
- tasks:
- - include_vars: ../conf/instance_settings.yml
-
- - name: Download JDK
- shell: "wget -q --tries=5 --no-cookies --no-check-certificate --header \
- \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie\" \
- \"http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.rpm\""
-
- - name: Install JDK
- shell: sudo yum -y localinstall jdk-8u121-linux-x64.rpm
-
- - name: Deploy binaries
- synchronize:
- src: "{{ dist }}"
- dest: "{{ binarydir }}"
- archive: true
-
- - name: Ensure the log directory exists
- file:
- path: "{{ binarydir }}/logs"
- state: directory
-
-- hosts: ncs
- tasks:
- - include_vars: ../conf/instance_settings.yml
-
-
- - name: Ensure the io device directory exit
- file:
- path: "{{ basedir }}/iodevice"
- state: directory
-
- - name: Start NC Service
- shell: nohup "{{ ncservice }}" &> "{{ binarydir }}/logs/ncservice.log" &
- async: 10
- poll: 0
-
-- hosts: cc
- tasks:
- - include_vars: ../conf/instance_settings.yml
-
- - name: Copy cluster config to CC
- synchronize:
- src: /tmp/asterixdb/cc.conf
- dest: "{{ basedir }}/cc.conf"
-
- - name: Update cluster config
- shell: find -P "{{ basedir }}/cc.conf"|xargs perl -pi -e 's|command=asterixnc|command={{ ncbin }}|g'
-
- - name: Start CC
- shell: nohup "{{ cc }}" -config-file "{{ basedir }}/cc.conf" &> "{{ binarydir }}/logs/cc.log" &
- async: 10
- poll: 0
diff --git a/asterixdb/asterix-server/src/main/opt/aws/bin/start.sh b/asterixdb/asterix-server/src/main/opt/aws/bin/start.sh
index 2627a09..a836b4e 100755
--- a/asterixdb/asterix-server/src/main/opt/aws/bin/start.sh
+++ b/asterixdb/asterix-server/src/main/opt/aws/bin/start.sh
@@ -27,7 +27,7 @@
DIST_PATH=`dirname "${OPT_PATH}"`
# Starts an AWS cluster.
-ansible-playbook -i "localhost," $AWS_PATH/ansible/aws_start.yml
+ansible-playbook -i "localhost," $AWS_PATH/yaml/aws_start.yml
# Generates an Ansible inventory file and an AsterixDB configuration file.
temp=/tmp/asterixdb
@@ -35,5 +35,5 @@
# Installs asterixdb on all AWS instances.
export ANSIBLE_HOST_KEY_CHECKING=false
-ansible-playbook -i $inventory $AWS_PATH/ansible/instance_start.yml
+ansible-playbook -i $inventory $AWS_PATH/yaml/instance_start.yml
diff --git a/asterixdb/asterix-server/src/main/opt/aws/bin/stop.sh b/asterixdb/asterix-server/src/main/opt/aws/bin/stop.sh
index 0f8bf98..48f4ff7 100755
--- a/asterixdb/asterix-server/src/main/opt/aws/bin/stop.sh
+++ b/asterixdb/asterix-server/src/main/opt/aws/bin/stop.sh
@@ -25,4 +25,4 @@
AWS_PATH=`dirname "${SCRIPT_PATH}"`
# Terminates an AWS cluster.
-ansible-playbook -i "localhost," $AWS_PATH/ansible/aws_stop.yml
+ansible-playbook -i "localhost," $AWS_PATH/yaml/aws_stop.yml
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_start.yml b/asterixdb/asterix-server/src/main/opt/aws/yaml/aws_start.yml
similarity index 93%
rename from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_start.yml
rename to asterixdb/asterix-server/src/main/opt/aws/yaml/aws_start.yml
index 645f68f..e0abb12 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_start.yml
+++ b/asterixdb/asterix-server/src/main/opt/aws/yaml/aws_start.yml
@@ -37,9 +37,7 @@
region: "{{ region }}"
aws_access_key: "{{ access_key_id }}"
aws_secret_key: "{{ secret_access_key }}"
- exact_count: "{{ count }}"
- count_tag:
- Name: "{{ tag }}"
+ count: "{{ count }}"
instance_tags:
Name: "{{ tag }}"
register: ec2
@@ -102,7 +100,3 @@
- name: Populate the NC command to the cluster configuration file {{ ccconf }}
shell: printf "command=asterixnc\n" >> "{{ ccconf }}"
-
- - name: Wait for SSH to come up
- wait_for: host="{{ item.public_ip }}" port=22 search_regex=OpenSSH delay=0 timeout=300 state=started
- with_items: "{{ ec2.instances }}"
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/aws/yaml/aws_stop.yml
similarity index 96%
rename from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
rename to asterixdb/asterix-server/src/main/opt/aws/yaml/aws_stop.yml
index e1bdc86..b466ad4 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/aws/yaml/aws_stop.yml
@@ -33,3 +33,5 @@
aws_access_key: "{{ access_key_id }}"
aws_secret_key: "{{ secret_access_key }}"
exact_count: 0
+ count_tag:
+ Name: "{{ tag }}"
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/aws/yaml/install_jdk.yml
similarity index 65%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/aws/yaml/install_jdk.yml
index e1bdc86..05838bd 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/aws/yaml/install_jdk.yml
@@ -17,19 +17,10 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
- tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+- name: Download JDK
+ shell: "wget -q --tries=5 --no-cookies --no-check-certificate --header \
+ \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie\" \
+ \"http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.rpm\""
+
+- name: Install JDK
+ shell: sudo yum -y localinstall jdk-8u121-linux-x64.rpm
diff --git a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml b/asterixdb/asterix-server/src/main/opt/aws/yaml/instance_start.yml
similarity index 66%
copy from asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
copy to asterixdb/asterix-server/src/main/opt/aws/yaml/instance_start.yml
index e1bdc86..7a5a840 100644
--- a/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
+++ b/asterixdb/asterix-server/src/main/opt/aws/yaml/instance_start.yml
@@ -17,19 +17,28 @@
# under the License.
# ------------------------------------------------------------
-- name: Stop AWS cluster
- hosts: localhost
- gather_facts: false
+
+- hosts: [localhost,]
tasks:
- - include_vars: ../conf/aws_settings.yml
- - name: Stop all instance
- ec2:
- key_name: "{{ keypair }}"
- group: "{{ group }}"
- instance_type: "{{ instance_type }}"
- image: "{{ image }}"
- wait: true
- region: "{{ region }}"
- aws_access_key: "{{ access_key_id }}"
- aws_secret_key: "{{ secret_access_key }}"
- exact_count: 0
+ - include: wait_ssh.yml
+
+- hosts: all
+ tasks:
+ - include: install_jdk.yml
+
+ - include_vars: ../conf/instance_settings.yml
+
+ - include: deploy.yml
+
+- hosts: ncs
+ tasks:
+ - include_vars: ../conf/instance_settings.yml
+
+ - include: start_ncservice.yml
+
+- hosts: cc
+ tasks:
+ - include_vars: ../conf/instance_settings.yml
+
+ - include: start_cc.yml
+