summaryrefslogtreecommitdiffstats
path: root/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible
diff options
context:
space:
mode:
authorQiaowei Ren <qiaowei.ren@intel.com>2018-01-04 13:43:33 +0800
committerQiaowei Ren <qiaowei.ren@intel.com>2018-01-05 11:59:39 +0800
commit812ff6ca9fcd3e629e49d4328905f33eee8ca3f5 (patch)
tree04ece7b4da00d9d2f98093774594f4057ae561d4 /src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible
parent15280273faafb77777eab341909a3f495cf248d9 (diff)
initial code repo
This patch creates initial code repo. For ceph, luminous stable release will be used for base code, and next changes and optimization for ceph will be added to it. For opensds, currently any changes can be upstreamed into original opensds repo (https://github.com/opensds/opensds), and so stor4nfv will directly clone opensds code to deploy stor4nfv environment. And the scripts for deployment based on ceph and opensds will be put into 'ci' directory. Change-Id: I46a32218884c75dda2936337604ff03c554648e4 Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Diffstat (limited to 'src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible')
-rw-r--r--src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/README32
-rwxr-xr-xsrc/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/ceph_install.sh39
-rw-r--r--src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/config5
l---------src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/copy_func.sh1
-rwxr-xr-xsrc/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/cdn_setup.sh20
-rwxr-xr-xsrc/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/ceph_ansible.sh36
-rwxr-xr-xsrc/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_ansible_hosts.sh17
-rwxr-xr-xsrc/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_groupvars_osds.sh13
-rwxr-xr-xsrc/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/multi_action.sh19
-rwxr-xr-xsrc/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/repolocs.sh8
-rwxr-xr-xsrc/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/staller.sh15
-rwxr-xr-xsrc/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/talknice.sh29
12 files changed, 234 insertions, 0 deletions
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/README b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/README
new file mode 100644
index 0000000..282c46e
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/README
@@ -0,0 +1,32 @@
+
+ceph_install.sh installs a ceph cluster using the cdn and ceph-ansible.
+
+Right now, it takes 5 parameters -- an admin node, a ceph mon node, and
+three osd nodes.
+
+In order to subscribe to the cdn, in your home directory create a file named
+secrets, (~/secrets), that contains the following lines:
+
+subscrname=Your-Redhat-Cdn-Id
+subscrpassword=Your-Redhat-Cdn-Password
+
+If you want to set the monitor_interface or the public_network values,
+in your home directory create a file named ip_info (~/ip_info), that
+contains the following lines:
+
+mon_intf=your-monitor-interface (default is eno1)
+pub_netw=public-network (default is 10.8.128.0/21)
+
+This script first subscribes to the cdn, enables the rhel 7 repos, and does
+a yum update. (multi_action.sh performs all the actions on all nodes at once,
+staller.sh is used to make sure that all updates are complete before exiting,
+and execs/cdn_setup.sh is used to remotely update the cdn information.
+
+After that, it makes sure that all nodes can connect via passwordless ssh
+(using talknice.sh and config) and then installs the appropriate repos and
+runs ceph_ansible on the admin node using execs/ceph_ansible.sh,
+execs/edit_ansible_hosts.sh and execs/edit_groupvars_osds.sh.
+
+repolocs.sh contains the locations of repo files. These variables can
+be changed if one wishes to use different urls.
+
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/ceph_install.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/ceph_install.sh
new file mode 100755
index 0000000..76a2e8a
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/ceph_install.sh
@@ -0,0 +1,39 @@
+#! /bin/bash
+if [ $# -ne 5 ]; then
+ echo 'Usage: ceph_install.sh <admin-node> <mon-node> <osd-node> <osd-node> <osd-node>'
+ exit -1
+fi
+allnodes=$*
+adminnode=$1
+shift
+cephnodes=$*
+monnode=$1
+shift
+osdnodes=$*
+./multi_action.sh cdn_setup.sh $allnodes
+./talknice.sh $allnodes
+for mac in $allnodes; do
+ ssh $mac sudo yum -y install yum-utils
+done
+
+source ./repolocs.sh
+ssh $adminnode sudo yum-config-manager --add ${CEPH_REPO_TOOLS}
+ssh $monnode sudo yum-config-manager --add ${CEPH_REPO_MON}
+for mac in $osdnodes; do
+ ssh $mac sudo yum-config-manager --add ${CEPH_REPO_OSD}
+done
+ssh $adminnode sudo yum-config-manager --add ${INSTALLER_REPO_LOC}
+
+for mac in $allnodes; do
+ ssh $mac sudo sed -i 's/gpgcheck=1/gpgcheck=0/' /etc/yum.conf
+done
+
+source copy_func.sh
+copy_file execs/ceph_ansible.sh $adminnode . 0777 ubuntu:ubuntu
+copy_file execs/edit_ansible_hosts.sh $adminnode . 0777 ubuntu:ubuntu
+copy_file execs/edit_groupvars_osds.sh $adminnode . 0777 ubuntu:ubuntu
+copy_file ../execs/ceph-pool-create.sh $monnode . 0777 ubuntu:ubuntu
+if [ -e ~/ip_info ]; then
+ copy_file ~/ip_info $adminnode . 0777 ubuntu:ubuntu
+fi
+ssh $adminnode ./ceph_ansible.sh $cephnodes
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/config b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/config
new file mode 100644
index 0000000..a7d8198
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/config
@@ -0,0 +1,5 @@
+Host plana* mira* burnupi* tala* saya* vpm* names* gitbuilder* teuthology gw* senta* vercoi* rex* magna*
+ ServerAliveInterval 360
+ StrictHostKeyChecking no
+ UserKnownHostsFile=/dev/null
+ User ubuntu
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/copy_func.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/copy_func.sh
new file mode 120000
index 0000000..6a36be7
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/copy_func.sh
@@ -0,0 +1 @@
+../copy_func.sh \ No newline at end of file
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/cdn_setup.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/cdn_setup.sh
new file mode 100755
index 0000000..5f2d05a
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/cdn_setup.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+if [ -f ~/secrets ]; then
+ source ~/secrets
+fi
+subm=`which subscription-manager`
+if [ ${#subm} -eq 0 ]; then
+ sudo yum -y update
+ exit
+fi
+subst=`sudo subscription-manager status | grep "^Overall" | awk '{print $NF}'`
+if [ $subst == 'Unknown' ]; then
+ mynameis=${subscrname:-'inigomontoya'}
+ mypassis=${subscrpassword:-'youkeelmyfatherpreparetodie'}
+ sudo subscription-manager register --username=$mynameis --password=$mypassis --force
+ sudo subscription-manager refresh
+ if [ $? -eq 1 ]; then exit 1; fi
+ sudo subscription-manager attach --pool=8a85f9823e3d5e43013e3ddd4e2a0977
+fi
+sudo subscription-manager repos --enable=rhel-7-server-rpms
+sudo yum -y update
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/ceph_ansible.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/ceph_ansible.sh
new file mode 100755
index 0000000..6a2a2ba
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/ceph_ansible.sh
@@ -0,0 +1,36 @@
+#! /bin/bash
+cephnodes=$*
+monnode=$1
+sudo yum -y install ceph-ansible
+cd
+sudo ./edit_ansible_hosts.sh $cephnodes
+mkdir ceph-ansible-keys
+cd /usr/share/ceph-ansible/group_vars/
+if [ -f ~/ip_info ]; then
+ source ~/ip_info
+fi
+mon_intf=${mon_intf:-'eno1'}
+pub_netw=${pub_netw:-'10.8.128.0\/21'}
+sudo cp all.sample all
+sudo sed -i 's/#ceph_origin:.*/ceph_origin: distro/' all
+sudo sed -i 's/#fetch_directory:.*/fetch_directory: ~\/ceph-ansible-keys/' all
+sudo sed -i 's/#ceph_stable:.*/ceph_stable: true/' all
+sudo sed -i 's/#ceph_stable_rh_storage:.*/ceph_stable_rh_storage: false/' all
+sudo sed -i 's/#ceph_stable_rh_storage_cdn_install:.*/ceph_stable_rh_storage_cdn_install: true/' all
+sudo sed -i 's/#cephx:.*/cephx: true/' all
+sudo sed -i "s/#monitor_interface:.*/monitor_interface: ${mon_intf}/" all
+sudo sed -i 's/#journal_size:.*/journal_size: 1024/' all
+sudo sed -i "s/#public_network:.*/public_network: ${pub_netw}/" all
+sudo cp osds.sample osds
+sudo sed -i 's/#fetch_directory:.*/fetch_directory: ~\/ceph-ansible-keys/' osds
+sudo sed -i 's/#crush_location:/crush_location:/' osds
+sudo sed -i 's/#osd_crush_location:/osd_crush_location:/' osds
+sudo sed -i 's/#cephx:/cephx:/' osds
+sudo sed -i 's/#devices:/devices:/' osds
+sudo sed -i 's/#journal_collocation:.*/journal_collocation: true/' osds
+cd
+sudo ./edit_groupvars_osds.sh
+cd /usr/share/ceph-ansible
+sudo cp site.yml.sample site.yml
+ansible-playbook site.yml
+ssh $monnode ~/ceph-pool-create.sh
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_ansible_hosts.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_ansible_hosts.sh
new file mode 100755
index 0000000..c3d8df6
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_ansible_hosts.sh
@@ -0,0 +1,17 @@
+#! /bin/bash
+ed /etc/ansible/hosts << EOF
+$
+a
+
+[mons]
+${1}
+
+[osds]
+${2}
+${3}
+${4}
+
+.
+w
+q
+EOF
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_groupvars_osds.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_groupvars_osds.sh
new file mode 100755
index 0000000..a62ef14
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_groupvars_osds.sh
@@ -0,0 +1,13 @@
+#! /bin/bash
+ed /usr/share/ceph-ansible/group_vars/osds << EOF
+$
+/^devices:
+.+1
+i
+ - /dev/sdb
+ - /dev/sdc
+ - /dev/sdd
+.
+w
+q
+EOF
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/multi_action.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/multi_action.sh
new file mode 100755
index 0000000..9fc2dde
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/multi_action.sh
@@ -0,0 +1,19 @@
+#! /bin/bash
+source copy_func.sh
+allparms=$*
+cmdv=$1
+shift
+sites=$*
+for mac in $sites; do
+ echo $cmdv $mac
+ if [ -f ~/secrets ]; then
+ copy_file ~/secrets $mac . 0777 ubuntu:ubuntu
+ fi
+ copy_file execs/${cmdv} $mac . 0777 ubuntu:ubuntu
+ ssh $mac ./${cmdv} &
+done
+./staller.sh $allparms
+for mac in $sites; do
+ ssh $mac sudo rm -rf secrets
+done
+echo "DONE"
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/repolocs.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/repolocs.sh
new file mode 100755
index 0000000..e4b74af
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/repolocs.sh
@@ -0,0 +1,8 @@
+#! /bin/bash
+SPECIFIC_VERSION=latest-Ceph-2-RHEL-7
+#SPECIFIC_VERSION=Ceph-2-RHEL-7-20160630.t.0
+#SPECIFIC_VERSION=Ceph-2.0-RHEL-7-20160718.t.0
+export CEPH_REPO_TOOLS=http://download.eng.bos.redhat.com/rcm-guest/ceph-drops/auto/ceph-2-rhel-7-compose/${SPECIFIC_VERSION}/compose/Tools/x86_64/os/
+export CEPH_REPO_MON=http://download.eng.bos.redhat.com/rcm-guest/ceph-drops/auto/ceph-2-rhel-7-compose/${SPECIFIC_VERSION}/compose/MON/x86_64/os/
+export CEPH_REPO_OSD=http://download.eng.bos.redhat.com/rcm-guest/ceph-drops/auto/ceph-2-rhel-7-compose/${SPECIFIC_VERSION}/compose/OSD/x86_64/os/
+export INSTALLER_REPO_LOC=http://download.eng.bos.redhat.com/rcm-guest/ceph-drops/auto/rhscon-2-rhel-7-compose/latest-RHSCON-2-RHEL-7/compose/Installer/x86_64/os/
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/staller.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/staller.sh
new file mode 100755
index 0000000..2e56002
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/staller.sh
@@ -0,0 +1,15 @@
+#! /bin/bash
+cmd_wait=$1
+shift
+sites=$*
+donebit=0
+while [ $donebit -ne 1 ]; do
+ sleep 10
+ donebit=1
+ for rem in $sites; do
+ rval=`ssh $rem ps aux | grep $cmd_wait | wc -l`
+ if [ $rval -gt 0 ]; then
+ donebit=0
+ fi
+ done
+done
diff --git a/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/talknice.sh b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/talknice.sh
new file mode 100755
index 0000000..6b538cd
--- /dev/null
+++ b/src/ceph/qa/qa_scripts/openstack/ceph_install_w_ansible/talknice.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+declare -A rsapub
+for fulln in $*; do
+ sname=`echo $fulln | sed 's/\..*//'`
+ nhead=`echo $sname | sed 's/[0-9]*//g'`
+ x=`ssh $fulln "ls .ssh/id_rsa"`
+ if [ -z $x ]; then
+ ssh $fulln "ssh-keygen -N '' -f .ssh/id_rsa";
+ fi
+ xx=`ssh $fulln "ls .ssh/config"`
+ if [ -z $xx ]; then
+ scp config $fulln:/home/ubuntu/.ssh/config
+ fi
+ ssh $fulln "chown ubuntu:ubuntu .ssh/config"
+ ssh $fulln "chmod 0600 .ssh/config"
+ rsapub[$fulln]=`ssh $fulln "cat .ssh/id_rsa.pub"`
+done
+for ii in $*; do
+ ssh $ii sudo iptables -F
+ for jj in $*; do
+ pval=${rsapub[$jj]}
+ if [ "$ii" != "$jj" ]; then
+ xxxx=`ssh $ii "grep $jj .ssh/authorized_keys"`
+ if [ -z "$xxxx" ]; then
+ ssh $ii "echo '$pval' | sudo tee -a /home/ubuntu/.ssh/authorized_keys"
+ fi
+ fi
+ done;
+done