From 94015c8da50dc231942e3a237652f92d0bc3de3d Mon Sep 17 00:00:00 2001 From: Fatih Degirmenci Date: Tue, 21 Mar 2017 22:34:52 +0100 Subject: [PATCH] xci: Updates to releng/osa to make it work on Jenkins - change OSA_BRANCH to OPENSTACK_BRANCH to be consistent everywhere. - create opnfv-setup-openstack.yml playbook, getting rid of some components and copy it to xcimaster to use during the deployment. - switch to opnfv-setup-openstack.yml from setup-openstack.yml. - create Jenkins job wrapper to execute osa deploy script. - disable ansible strict host key checking. - use sudo -E as needed in order to make env vars set by Jenkins job and wrapper available to other scripts and to ansible. - rename jumphost to xcimaster so people do not mix it with actual jumphost located in Pharos PODs. - other minor fixes. Change-Id: I5736fa700c2aa39c598d301bc74450d766b74411 Signed-off-by: Fatih Degirmenci --- jjb/xci/xci-deploy.sh | 69 +++++++++++++++++++++- .../file/opnfv-setup-openstack.yml | 36 +++++++++++ prototypes/openstack-ansible/playbooks/inventory | 4 +- .../playbooks/jumphost_configuration.yml | 10 +++- prototypes/openstack-ansible/scripts/osa_deploy.sh | 26 ++++---- prototypes/openstack-ansible/var/ubuntu.yml | 6 +- 6 files changed, 129 insertions(+), 22 deletions(-) create mode 100644 prototypes/openstack-ansible/file/opnfv-setup-openstack.yml diff --git a/jjb/xci/xci-deploy.sh b/jjb/xci/xci-deploy.sh index b97b24e47..5856f52e7 100755 --- a/jjb/xci/xci-deploy.sh +++ b/jjb/xci/xci-deploy.sh @@ -1,3 +1,70 @@ #!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2016 Ericsson AB and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +set -o errexit +set -o nounset +set -o pipefail -echo "Deployment via openstack-ansible" +trap cleanup_and_upload EXIT + +function fix_ownership() { + if [ -z "${JOB_URL+x}" ]; then + echo "Not running as part of Jenkins. Handle the logs manually." + else + # Make sure cache exists + [[ ! -d ${HOME}/.cache ]] && mkdir ${HOME}/.cache + + sudo chown -R jenkins:jenkins $WORKSPACE + sudo chown -R jenkins:jenkins ${HOME}/.cache + fi +} + +function cleanup_and_upload() { + original_exit=$? + fix_ownership + exit $original_exit +} + +# check distro to see if we support it +if [[ ! "$DISTRO" =~ (xenial|centos7|suse) ]]; then + echo "Distro $DISTRO is not supported!" + exit 1 +fi + +# remove previously cloned repos +sudo /bin/rm -rf /opt/openstack-ansible /opt/stack /opt/releng /opt/functest + +# Fix up permissions +fix_ownership + +# openstack-ansible enables strict host key checking by default +export ANSIBLE_HOST_KEY_CHECKING=False + +# display the nodes +cd /opt/bifrost +source env-vars +ironic node-list +virsh list + +# ensure the branches to use are set +export OPNFV_BRANCH=${OPNFV_BRANCH:-master} +export OPENSTACK_BRANCH=${OPENSTACK_BRANCH:-master} + +# clone releng repo +sudo git clone -b $OPNFV_BRANCH https://gerrit.opnfv.org/gerrit/releng /opt/releng + +# this script will be reused for promoting openstack-ansible versions and using +# promoted openstack-ansible versions as part of xci daily. +USE_PROMOTED_VERSIONS=${USE_PROMOTED_VERSIONS:-false} +if [ $USE_PROMOTED_VERSIONS = "true" ]; then + echo "TBD: Will use the promoted versions of openstack/opnfv projects" +fi + +cd /opt/releng/prototypes/openstack-ansible/scripts +sudo -E ./osa_deploy.sh diff --git a/prototypes/openstack-ansible/file/opnfv-setup-openstack.yml b/prototypes/openstack-ansible/file/opnfv-setup-openstack.yml new file mode 100644 index 000000000..b3deba08d --- /dev/null +++ b/prototypes/openstack-ansible/file/opnfv-setup-openstack.yml @@ -0,0 +1,36 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed 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. + +- include: os-keystone-install.yml +- include: os-barbican-install.yml +- include: os-glance-install.yml +- include: os-cinder-install.yml +- include: os-nova-install.yml +- include: os-neutron-install.yml +- include: os-heat-install.yml +- include: os-horizon-install.yml +- include: os-ceilometer-install.yml +- include: os-aodh-install.yml +- include: os-designate-install.yml +#NOTE(stevelle) Ensure Gnocchi identities exist before Swift +- include: os-gnocchi-install.yml + when: + - gnocchi_storage_driver is defined + - gnocchi_storage_driver == 'swift' + vars: + gnocchi_identity_only: True +- include: os-swift-install.yml +- include: os-gnocchi-install.yml +- include: os-ironic-install.yml diff --git a/prototypes/openstack-ansible/playbooks/inventory b/prototypes/openstack-ansible/playbooks/inventory index f53da5305..d3768f51c 100644 --- a/prototypes/openstack-ansible/playbooks/inventory +++ b/prototypes/openstack-ansible/playbooks/inventory @@ -1,5 +1,5 @@ -[jumphost] -jumphost ansible_ssh_host=192.168.122.2 +[xcimaster] +xcimaster ansible_ssh_host=192.168.122.2 [controller] controller00 ansible_ssh_host=192.168.122.3 diff --git a/prototypes/openstack-ansible/playbooks/jumphost_configuration.yml b/prototypes/openstack-ansible/playbooks/jumphost_configuration.yml index 74e97cdd5..b6c79a418 100644 --- a/prototypes/openstack-ansible/playbooks/jumphost_configuration.yml +++ b/prototypes/openstack-ansible/playbooks/jumphost_configuration.yml @@ -1,5 +1,5 @@ --- -- hosts: jumphost +- hosts: xcimaster remote_user: root vars_files: - ../var/ubuntu.yml @@ -13,7 +13,11 @@ - name: remove the directory shell: "rm -rf {{OSA_PATH}} {{OSA_ETC_PATH}}" - name: git openstack ansible - shell: "git clone {{OSA_URL}} {{OSA_PATH}} -b {{OSA_BRANCH}}" + shell: "git clone {{OSA_URL}} {{OSA_PATH}} -b {{OPENSTACK_BRANCH}}" + - name: copy opnfv-setup-openstack.yml to /opt/openstack-ansible/playbooks + copy: + src: ../file/opnfv-setup-openstack.yml + dest: "{{OSA_PATH}}/playbooks/opnfv-setup-openstack.yml" - name: copy /opt/openstack-ansible/etc/openstack_deploy to /etc/openstack_deploy shell: "/bin/cp -rf {{OSA_PATH}}/etc/openstack_deploy {{OSA_ETC_PATH}}" - name: bootstrap @@ -50,4 +54,4 @@ remote_user: root tasks: - name: Generate authorized_keys - shell: "/bin/cat /jumphost/root/.ssh/id_rsa.pub >> ../file/authorized_keys" + shell: "/bin/cat /xcimaster/root/.ssh/id_rsa.pub >> ../file/authorized_keys" diff --git a/prototypes/openstack-ansible/scripts/osa_deploy.sh b/prototypes/openstack-ansible/scripts/osa_deploy.sh index 79625d211..afc8368b1 100755 --- a/prototypes/openstack-ansible/scripts/osa_deploy.sh +++ b/prototypes/openstack-ansible/scripts/osa_deploy.sh @@ -3,27 +3,27 @@ export OSA_PATH=/opt/openstack-ansible export LOG_PATH=$OSA_PATH/log export PLAYBOOK_PATH=$OSA_PATH/playbooks -export OSA_BRANCH=${OSA_BRANCH:-"master"} -JUMPHOST_IP="192.168.122.2" +export OPENSTACK_BRANCH=${OPENSTACK_BRANCH:-"master"} +XCIMASTER_IP="192.168.122.2" sudo /bin/rm -rf $LOG_PATH sudo /bin/mkdir -p $LOG_PATH sudo /bin/cp /root/.ssh/id_rsa.pub ../file/authorized_keys -sudo echo -e '\n'>>../file/authorized_keys +echo -e '\n' | sudo tee --append ../file/authorized_keys cd ../playbooks/ # this will prepare the jump host # git clone the Openstack-Ansible, bootstrap and configure network -sudo ansible-playbook -i inventory jumphost_configuration.yml -vvv +sudo -E ansible-playbook -i inventory jumphost_configuration.yml # this will prepare the target host # such as configure network and NFS -sudo ansible-playbook -i inventory targethost_configuration.yml +sudo -E ansible-playbook -i inventory targethost_configuration.yml # using OpenStack-Ansible deploy the OpenStack echo "set UP Host !" -sudo /bin/sh -c "ssh root@$JUMPHOST_IP openstack-ansible \ +sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \ $PLAYBOOK_PATH/setup-hosts.yml" | \ tee $LOG_PATH/setup-host.log @@ -39,7 +39,7 @@ else fi echo "Set UP Infrastructure !" -sudo /bin/sh -c "ssh root@$JUMPHOST_IP openstack-ansible \ +sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \ $PLAYBOOK_PATH/setup-infrastructure.yml" | \ tee $LOG_PATH/setup-infrastructure.log @@ -52,7 +52,7 @@ else echo "setup infrastructure successfully!" fi -sudo /bin/sh -c "ssh root@$JUMPHOST_IP ansible -i $PLAYBOOK_PATH/inventory/ \ +sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP ansible -i $PLAYBOOK_PATH/inventory/ \ galera_container -m shell \ -a "mysql -h localhost -e 'show status like \"%wsrep_cluster_%\";'"" \ | tee $LOG_PATH/galera.log @@ -66,12 +66,12 @@ else fi echo "Set UP OpenStack !" -sudo /bin/sh -c "ssh root@$JUMPHOST_IP openstack-ansible \ - $PLAYBOOK_PATH/setup-openstack.yml" | \ - tee $LOG_PATH/setup-openstack.log +sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \ + $PLAYBOOK_PATH/opnfv-setup-openstack.yml" | \ + tee $LOG_PATH/opnfv-setup-openstack.log -grep "failed=1" $LOG_PATH/setup-openstack.log>/dev/null \ - || grep "unreachable=1" $LOG_PATH/setup-openstack.log>/dev/null +grep "failed=1" $LOG_PATH/opnfv-setup-openstack.log>/dev/null \ + || grep "unreachable=1" $LOG_PATH/opnfv-setup-openstack.log>/dev/null if [ $? -eq 0 ]; then echo "failed setup openstack!" exit 1 diff --git a/prototypes/openstack-ansible/var/ubuntu.yml b/prototypes/openstack-ansible/var/ubuntu.yml index 9464384b3..321a7c4e5 100644 --- a/prototypes/openstack-ansible/var/ubuntu.yml +++ b/prototypes/openstack-ansible/var/ubuntu.yml @@ -2,7 +2,7 @@ OSA_URL: https://git.openstack.org/openstack/openstack-ansible OSA_PATH: /opt/openstack-ansible OSA_ETC_PATH: /etc/openstack_deploy -OSA_BRANCH: "{{ lookup('env','OSA_BRANCH') }}" +OPENSTACK_BRANCH: "{{ lookup('env','OPENSTACK_BRANCH') }}" -JUMPHOST_IP: 192.168.122.2 -host_info: {'jumphost':{'MGMT_IP': '172.29.236.10','VLAN_IP': '192.168.122.2', 'STORAGE_IP': '172.29.244.10'},'controller00':{'MGMT_IP': '172.29.236.11','VLAN_IP': '192.168.122.3', 'STORAGE_IP': '172.29.244.11'},'controller01':{'MGMT_IP': '172.29.236.12','VLAN_IP': '192.168.122.4', 'STORAGE_IP': '172.29.244.12'},'controller02':{'MGMT_IP': '172.29.236.13','VLAN_IP': '192.168.122.5', 'STORAGE_IP': '172.29.240.13'},'compute00':{'MGMT_IP': '172.29.236.14','VLAN_IP': '192.168.122.6','VLAN_IP_SECOND': '173.29.241.1','VXLAN_IP': '172.29.240.14', 'STORAGE_IP': '172.29.244.14'},'compute01':{'MGMT_IP': '172.29.236.15','VLAN_IP': '192.168.122.7','VLAN_IP_SECOND': '173.29.241.2','VXLAN_IP': '172.29.240.15', 'STORAGE_IP': '172.29.244.15'}} +XCIMASTER_IP: 192.168.122.2 +host_info: {'xcimaster':{'MGMT_IP': '172.29.236.10','VLAN_IP': '192.168.122.2', 'STORAGE_IP': '172.29.244.10'},'controller00':{'MGMT_IP': '172.29.236.11','VLAN_IP': '192.168.122.3', 'STORAGE_IP': '172.29.244.11'},'controller01':{'MGMT_IP': '172.29.236.12','VLAN_IP': '192.168.122.4', 'STORAGE_IP': '172.29.244.12'},'controller02':{'MGMT_IP': '172.29.236.13','VLAN_IP': '192.168.122.5', 'STORAGE_IP': '172.29.240.13'},'compute00':{'MGMT_IP': '172.29.236.14','VLAN_IP': '192.168.122.6','VLAN_IP_SECOND': '173.29.241.1','VXLAN_IP': '172.29.240.14', 'STORAGE_IP': '172.29.244.14'},'compute01':{'MGMT_IP': '172.29.236.15','VLAN_IP': '192.168.122.7','VLAN_IP_SECOND': '173.29.241.2','VXLAN_IP': '172.29.240.15', 'STORAGE_IP': '172.29.244.15'}} -- 2.16.6