From: Warren Usui Date: Thu, 21 Jul 2016 21:03:13 +0000 (-0400) Subject: Add ceph-ansible installer. X-Git-Tag: v11.1.0~164^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=69c12e8d3b50504033b42d6fd09798603837fd81;p=ceph.git Add ceph-ansible installer. Also fix iso rhel handling in openstack script Updated openstack README. Fixes: http://tracker.ceph.com/issues/16770 Signed-off-by: Warren Usui --- diff --git a/qa/qa_scripts/openstack/README b/qa/qa_scripts/openstack/README index 4b593171176..63fe2d973d7 100644 --- a/qa/qa_scripts/openstack/README +++ b/qa/qa_scripts/openstack/README @@ -10,9 +10,23 @@ If further development is necessary in the future, these templates should probably be removed and direct editing of the OpenStack conf files should probably be performed. -These scripts also assume that there is a rhel iso file named -rhel-server-7.2-x86_64-boot.iso and a ceph iso file named -rhceph-1.3.1-rhel-7-x86_64-dvd.iso in the files directory. These iso files -can be obtained from the rhel site and are not stored with these scripts. +These scripts also assume that either there is a rhel iso file named +rhel-server-7.2-x86_64-boot.iso in the user's home directory, or the +exported variable RHEL_ISO is set to point at an existing rhel iso file. +If one is also running the ceph-deploy based ceph_install.sh, this script +also assumes that there is a file named rhceph-1.3.1-rhel-7-x86_64-dvd.iso +in the files directory. These iso files can be obtained from the rhel site +and are not stored with these scripts. +To install openstack: +./openstack.sh + +This assumes that the ceph cluster is already set up. + +To setup a ceph-cluster using an iso and ceph-deploy: +./ceph_install.sh + +To setup a ceph-cluster using the cdn and ceph-ansible: +cd ceph_install_w_ansible +./ceph_install.sh diff --git a/qa/qa_scripts/openstack/ceph_install_w_ansible/README b/qa/qa_scripts/openstack/ceph_install_w_ansible/README new file mode 100644 index 00000000000..bed8bad56cf --- /dev/null +++ b/qa/qa_scripts/openstack/ceph_install_w_ansible/README @@ -0,0 +1,24 @@ +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 + +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/qa/qa_scripts/openstack/ceph_install_w_ansible/ceph_install.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/ceph_install.sh new file mode 100755 index 00000000000..72f0db144bf --- /dev/null +++ b/qa/qa_scripts/openstack/ceph_install_w_ansible/ceph_install.sh @@ -0,0 +1,36 @@ +#! /bin/bash +if [ $# -ne 5 ]; then + echo 'Usage: ceph_install.sh ' + 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 +ssh $adminnode ./ceph_ansible.sh $cephnodes diff --git a/qa/qa_scripts/openstack/ceph_install_w_ansible/config b/qa/qa_scripts/openstack/ceph_install_w_ansible/config new file mode 100644 index 00000000000..a7d8198696a --- /dev/null +++ b/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/qa/qa_scripts/openstack/ceph_install_w_ansible/copy_func.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/copy_func.sh new file mode 120000 index 00000000000..6a36be7b060 --- /dev/null +++ b/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/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/cdn_setup.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/cdn_setup.sh new file mode 100755 index 00000000000..76cc07e4a3f --- /dev/null +++ b/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/cdn_setup.sh @@ -0,0 +1,12 @@ +#! /bin/bash +if [ -f ~/secrets ]; then + source ~/secrets +fi +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 +sudo subscription-manager repos --enable=rhel-7-server-rpms +sudo yum -y update diff --git a/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/ceph_ansible.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/ceph_ansible.sh new file mode 100755 index 00000000000..d25dc34a5e6 --- /dev/null +++ b/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/ceph_ansible.sh @@ -0,0 +1,31 @@ +#! /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/ +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: eno1/' all +sudo sed -i 's/#journal_size:.*/journal_size: 1024/' all +sudo sed -i 's/#public_network:.*/public_network: 10.8.128.0\/21/' 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/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_ansible_hosts.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_ansible_hosts.sh new file mode 100755 index 00000000000..c3d8df6b2bf --- /dev/null +++ b/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/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_groupvars_osds.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/execs/edit_groupvars_osds.sh new file mode 100755 index 00000000000..a62ef140072 --- /dev/null +++ b/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/qa/qa_scripts/openstack/ceph_install_w_ansible/multi_action.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/multi_action.sh new file mode 100755 index 00000000000..9fc2dde2604 --- /dev/null +++ b/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/qa/qa_scripts/openstack/ceph_install_w_ansible/repolocs.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/repolocs.sh new file mode 100755 index 00000000000..e4b74af18ad --- /dev/null +++ b/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/qa/qa_scripts/openstack/ceph_install_w_ansible/staller.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/staller.sh new file mode 100755 index 00000000000..2e560024cb8 --- /dev/null +++ b/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/qa/qa_scripts/openstack/ceph_install_w_ansible/talknice.sh b/qa/qa_scripts/openstack/ceph_install_w_ansible/talknice.sh new file mode 100755 index 00000000000..6b538cd6bcf --- /dev/null +++ b/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 diff --git a/qa/qa_scripts/openstack/image_create.sh b/qa/qa_scripts/openstack/image_create.sh index 82e535325dd..4252dd8837a 100755 --- a/qa/qa_scripts/openstack/image_create.sh +++ b/qa/qa_scripts/openstack/image_create.sh @@ -1,13 +1,14 @@ #/bin/bash -fv # -# Set up a vm on packstack. Use the iso in the files directory. +# Set up a vm on packstack. Use the iso in RHEL_ISO (defaults to home dir) # source ./copy_func.sh source ./fix_conf_file.sh openstack_node=${1} ceph_node=${2} -copy_file files/rhel-server-7.2-x86_64-boot.iso $openstack_node . +RHEL_ISO=${RHEL_ISO:-~/rhel-server-7.2-x86_64-boot.iso} +copy_file ${RHEL_ISO} $openstack_node . copy_file execs/run_openstack.sh $openstack_node . 0755 filler=`date +%s` ssh $openstack_node ./run_openstack.sh "${openstack_node}X${filler}" rhel-server-7.2-x86_64-boot.iso diff --git a/qa/qa_scripts/openstack/openstack.sh b/qa/qa_scripts/openstack/openstack.sh index 59921f104bd..986fce91787 100755 --- a/qa/qa_scripts/openstack/openstack.sh +++ b/qa/qa_scripts/openstack/openstack.sh @@ -20,8 +20,8 @@ openstack_node=${1} ceph_node=${2} ./packstack.sh $openstack_node $ceph_node echo 'done running packstack' -read foo +sleep 60 ./connectceph.sh $openstack_node $ceph_node echo 'done connecting' -read foo +sleep 60 ./image_create.sh $openstack_node $ceph_node