From 68eb2ba33f9467d856838c61dc8e9c9d1cb35ded Mon Sep 17 00:00:00 2001 From: Fatih Degirmenci Date: Wed, 22 Mar 2017 11:29:21 +0100 Subject: xci: Logging, naming, and job updates - adjust build blockers in daily jobs. - explicity set SLAVE_LABEL for provision, deploy, and functest jobs so they run on correct nodes even if they are started manually. - rename files and update scripts accordingly. osa_deploy.sh -> osa-deploy.sh targethost_configuration.yml -> configure-targethosts.yml jumphost_configuration.yml -> configure-xcimaster.yml - add/fix console logging in osa-deploy.sh. - add license header to osa-deploy.sh. Change-Id: I57a37dccaa4bcda554ef79969e5d288b49937807 Signed-off-by: Fatih Degirmenci --- .../playbooks/configure-targethosts.yml | 61 ++++++++++ .../playbooks/configure-xcimaster.yml | 57 +++++++++ .../playbooks/jumphost_configuration.yml | 57 --------- .../playbooks/targethost_configuration.yml | 61 ---------- prototypes/openstack-ansible/scripts/osa-deploy.sh | 133 +++++++++++++++++++++ prototypes/openstack-ansible/scripts/osa_deploy.sh | 81 ------------- 6 files changed, 251 insertions(+), 199 deletions(-) create mode 100644 prototypes/openstack-ansible/playbooks/configure-targethosts.yml create mode 100644 prototypes/openstack-ansible/playbooks/configure-xcimaster.yml delete mode 100644 prototypes/openstack-ansible/playbooks/jumphost_configuration.yml delete mode 100644 prototypes/openstack-ansible/playbooks/targethost_configuration.yml create mode 100755 prototypes/openstack-ansible/scripts/osa-deploy.sh delete mode 100755 prototypes/openstack-ansible/scripts/osa_deploy.sh (limited to 'prototypes') diff --git a/prototypes/openstack-ansible/playbooks/configure-targethosts.yml b/prototypes/openstack-ansible/playbooks/configure-targethosts.yml new file mode 100644 index 000000000..1f4ad063e --- /dev/null +++ b/prototypes/openstack-ansible/playbooks/configure-targethosts.yml @@ -0,0 +1,61 @@ +--- +- hosts: all + remote_user: root + vars_files: + - ../var/ubuntu.yml + tasks: + - name: add public key to host + copy: + src: ../file/authorized_keys + dest: /root/.ssh/authorized_keys + - name: configure modules + copy: + src: ../file/modules + dest: /etc/modules + +- hosts: controller + remote_user: root + vars_files: + - ../var/ubuntu.yml + tasks: + - name: configure network + template: + src: ../template/bifrost/controller.interface.j2 + dest: /etc/network/interfaces + notify: + - restart network service + handlers: + - name: restart network service + shell: "/sbin/ifconfig ens3 0 &&/sbin/ifdown -a && /sbin/ifup -a" + +- hosts: compute + remote_user: root + vars_files: + - ../var/ubuntu.yml + tasks: + - name: configure network + template: + src: ../template/bifrost/compute.interface.j2 + dest: /etc/network/interfaces + notify: + - restart network service + handlers: + - name: restart network service + shell: "/sbin/ifconfig ens3 0 &&/sbin/ifdown -a && /sbin/ifup -a" + +- hosts: compute01 + remote_user: root + tasks: + - name: make nfs dir + file: "dest=/images mode=777 state=directory" + - name: configure sdrvice + shell: "echo 'nfs 2049/tcp' >> /etc/services && echo 'nfs 2049/udp' >> /etc/services" + - name: configure NFS + copy: + src: ../file/exports + dest: /etc/exports + notify: + - restart nfs service + handlers: + - name: restart nfs service + service: name=nfs-kernel-server state=restarted diff --git a/prototypes/openstack-ansible/playbooks/configure-xcimaster.yml b/prototypes/openstack-ansible/playbooks/configure-xcimaster.yml new file mode 100644 index 000000000..b6c79a418 --- /dev/null +++ b/prototypes/openstack-ansible/playbooks/configure-xcimaster.yml @@ -0,0 +1,57 @@ +--- +- hosts: xcimaster + remote_user: root + vars_files: + - ../var/ubuntu.yml + tasks: + - name: generate SSH keys + shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" + args: + creates: /root/.ssh/id_rsa + - name: fetch public key + fetch: src="/root/.ssh/id_rsa.pub" dest="/" + - name: remove the directory + shell: "rm -rf {{OSA_PATH}} {{OSA_ETC_PATH}}" + - name: git openstack ansible + 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 + command: "/bin/bash ./scripts/bootstrap-ansible.sh" + args: + chdir: "{{OSA_PATH}}" + - name: generate password token + command: "python pw-token-gen.py --file /etc/openstack_deploy/user_secrets.yml" + args: + chdir: /opt/openstack-ansible/scripts/ + - name: copy openstack_user_config.yml to /etc/openstack_deploy + copy: + src: ../file/openstack_user_config.yml + dest: "{{OSA_ETC_PATH}}/openstack_user_config.yml" + - name: copy cinder.yml to /etc/openstack_deploy/env.d + copy: + src: ../file/cinder.yml + dest: "{{OSA_ETC_PATH}}/env.d/cinder.yml" + - name: copy user_variables.yml to /etc/openstack_deploy/ + copy: + src: ../file/user_variables.yml + dest: "{{OSA_ETC_PATH}}/user_variables.yml" + - name: configure network + template: + src: ../template/bifrost/controller.interface.j2 + dest: /etc/network/interfaces + notify: + - restart network service + handlers: + - name: restart network service + shell: "/sbin/ifconfig ens3 0 &&/sbin/ifdown -a && /sbin/ifup -a" + +- hosts: localhost + remote_user: root + tasks: + - name: Generate authorized_keys + shell: "/bin/cat /xcimaster/root/.ssh/id_rsa.pub >> ../file/authorized_keys" diff --git a/prototypes/openstack-ansible/playbooks/jumphost_configuration.yml b/prototypes/openstack-ansible/playbooks/jumphost_configuration.yml deleted file mode 100644 index b6c79a418..000000000 --- a/prototypes/openstack-ansible/playbooks/jumphost_configuration.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -- hosts: xcimaster - remote_user: root - vars_files: - - ../var/ubuntu.yml - tasks: - - name: generate SSH keys - shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" - args: - creates: /root/.ssh/id_rsa - - name: fetch public key - fetch: src="/root/.ssh/id_rsa.pub" dest="/" - - name: remove the directory - shell: "rm -rf {{OSA_PATH}} {{OSA_ETC_PATH}}" - - name: git openstack ansible - 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 - command: "/bin/bash ./scripts/bootstrap-ansible.sh" - args: - chdir: "{{OSA_PATH}}" - - name: generate password token - command: "python pw-token-gen.py --file /etc/openstack_deploy/user_secrets.yml" - args: - chdir: /opt/openstack-ansible/scripts/ - - name: copy openstack_user_config.yml to /etc/openstack_deploy - copy: - src: ../file/openstack_user_config.yml - dest: "{{OSA_ETC_PATH}}/openstack_user_config.yml" - - name: copy cinder.yml to /etc/openstack_deploy/env.d - copy: - src: ../file/cinder.yml - dest: "{{OSA_ETC_PATH}}/env.d/cinder.yml" - - name: copy user_variables.yml to /etc/openstack_deploy/ - copy: - src: ../file/user_variables.yml - dest: "{{OSA_ETC_PATH}}/user_variables.yml" - - name: configure network - template: - src: ../template/bifrost/controller.interface.j2 - dest: /etc/network/interfaces - notify: - - restart network service - handlers: - - name: restart network service - shell: "/sbin/ifconfig ens3 0 &&/sbin/ifdown -a && /sbin/ifup -a" - -- hosts: localhost - remote_user: root - tasks: - - name: Generate authorized_keys - shell: "/bin/cat /xcimaster/root/.ssh/id_rsa.pub >> ../file/authorized_keys" diff --git a/prototypes/openstack-ansible/playbooks/targethost_configuration.yml b/prototypes/openstack-ansible/playbooks/targethost_configuration.yml deleted file mode 100644 index 1f4ad063e..000000000 --- a/prototypes/openstack-ansible/playbooks/targethost_configuration.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- -- hosts: all - remote_user: root - vars_files: - - ../var/ubuntu.yml - tasks: - - name: add public key to host - copy: - src: ../file/authorized_keys - dest: /root/.ssh/authorized_keys - - name: configure modules - copy: - src: ../file/modules - dest: /etc/modules - -- hosts: controller - remote_user: root - vars_files: - - ../var/ubuntu.yml - tasks: - - name: configure network - template: - src: ../template/bifrost/controller.interface.j2 - dest: /etc/network/interfaces - notify: - - restart network service - handlers: - - name: restart network service - shell: "/sbin/ifconfig ens3 0 &&/sbin/ifdown -a && /sbin/ifup -a" - -- hosts: compute - remote_user: root - vars_files: - - ../var/ubuntu.yml - tasks: - - name: configure network - template: - src: ../template/bifrost/compute.interface.j2 - dest: /etc/network/interfaces - notify: - - restart network service - handlers: - - name: restart network service - shell: "/sbin/ifconfig ens3 0 &&/sbin/ifdown -a && /sbin/ifup -a" - -- hosts: compute01 - remote_user: root - tasks: - - name: make nfs dir - file: "dest=/images mode=777 state=directory" - - name: configure sdrvice - shell: "echo 'nfs 2049/tcp' >> /etc/services && echo 'nfs 2049/udp' >> /etc/services" - - name: configure NFS - copy: - src: ../file/exports - dest: /etc/exports - notify: - - restart nfs service - handlers: - - name: restart nfs service - service: name=nfs-kernel-server state=restarted diff --git a/prototypes/openstack-ansible/scripts/osa-deploy.sh b/prototypes/openstack-ansible/scripts/osa-deploy.sh new file mode 100755 index 000000000..d30cf1b7b --- /dev/null +++ b/prototypes/openstack-ansible/scripts/osa-deploy.sh @@ -0,0 +1,133 @@ +#!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd 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 + +export OSA_PATH=/opt/openstack-ansible +export LOG_PATH=$OSA_PATH/log +export PLAYBOOK_PATH=$OSA_PATH/playbooks +export OSA_BRANCH=${OSA_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 +echo -e '\n' | sudo tee --append ../file/authorized_keys + +# log some info +echo -e "\n" +echo "***********************************************************************" +echo "* *" +echo "* Configure XCI Master *" +echo "* *" +echo "* Bootstrap xci-master, configure network, clone openstack-ansible *" +echo "* *" +echo "***********************************************************************" +echo -e "\n" + +cd ../playbooks/ +# this will prepare the jump host +# git clone the Openstack-Ansible, bootstrap and configure network +sudo -E ansible-playbook -i inventory configure-xcimaster.yml + +echo "XCI Master is configured successfully!" + +# log some info +echo -e "\n" +echo "***********************************************************************" +echo "* *" +echo "* Configure Nodes *" +echo "* *" +echo "* Configure network on OpenStack Nodes, configure NFS *" +echo "* *" +echo "***********************************************************************" +echo -e "\n" + +# this will prepare the target host +# such as configure network and NFS +sudo -E ansible-playbook -i inventory configure-targethosts.yml + +echo "Nodes are configured successfully!" + +# log some info +echo -e "\n" +echo "***********************************************************************" +echo "* *" +echo "* Set Up OpenStack Nodes *" +echo "* *" +echo "* Set up OpenStack Nodes using openstack-ansible *" +echo "* *" +echo "***********************************************************************" +echo -e "\n" + +# using OpenStack-Ansible deploy the OpenStack + +sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \ + $PLAYBOOK_PATH/setup-hosts.yml" | \ + tee $LOG_PATH/setup-host.log + +#check the result of openstack-ansible setup-hosts.yml +#if failed, exit with exit code 1 +grep "failed=1" $LOG_PATH/setup-host.log>/dev/null \ + || grep "unreachable=1" $LOG_PATH/setup-host.log>/dev/null +if [ $? -eq 0 ]; then + echo "OpenStack node setup failed!" + exit 1 +fi + +sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \ + $PLAYBOOK_PATH/setup-infrastructure.yml" | \ + tee $LOG_PATH/setup-infrastructure.log + +grep "failed=1" $LOG_PATH/setup-infrastructure.log>/dev/null \ + || grep "unreachable=1" $LOG_PATH/setup-infrastructure.log>/dev/null +if [ $? -eq 0 ]; then + echo "failed setup infrastructure!" + exit 1 +fi + +echo "OpenStack nodes are setup successfully!" + +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 + +grep "FAILED" $LOG_PATH/galera.log>/dev/null +if [ $? -eq 0 ]; then + echo "Database cluster verification failed!" + exit 1 +else + echo "Database cluster verification successful!" +fi + +# log some info +echo -e "\n" +echo "***********************************************************************" +echo "* *" +echo "* Install OpenStack *" +echo "* *" +echo "***********************************************************************" +echo -e "\n" + +sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \ + $PLAYBOOK_PATH/setup-openstack.yml" | \ + tee $LOG_PATH/setup-openstack.log + +grep "failed=1" $LOG_PATH/setup-openstack.log>/dev/null \ + || grep "unreachable=1" $LOG_PATH/setup-openstack.log>/dev/null +if [ $? -eq 0 ]; then + echo "OpenStack installation failed!" + exit 1 +else + echo "OpenStack installation is successfully completed!" + exit 0 +fi diff --git a/prototypes/openstack-ansible/scripts/osa_deploy.sh b/prototypes/openstack-ansible/scripts/osa_deploy.sh deleted file mode 100755 index afc8368b1..000000000 --- a/prototypes/openstack-ansible/scripts/osa_deploy.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - -export OSA_PATH=/opt/openstack-ansible -export LOG_PATH=$OSA_PATH/log -export PLAYBOOK_PATH=$OSA_PATH/playbooks -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 -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 -E ansible-playbook -i inventory jumphost_configuration.yml - -# this will prepare the target host -# such as configure network and NFS -sudo -E ansible-playbook -i inventory targethost_configuration.yml - -# using OpenStack-Ansible deploy the OpenStack - -echo "set UP Host !" -sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \ - $PLAYBOOK_PATH/setup-hosts.yml" | \ - tee $LOG_PATH/setup-host.log - -#check the result of openstack-ansible setup-hosts.yml -#if failed, exit with exit code 1 -grep "failed=1" $LOG_PATH/setup-host.log>/dev/null \ - || grep "unreachable=1" $LOG_PATH/setup-host.log>/dev/null -if [ $? -eq 0 ]; then - echo "failed setup host!" - exit 1 -else - echo "setup host successfully!" -fi - -echo "Set UP Infrastructure !" -sudo -E /bin/sh -c "ssh root@$XCIMASTER_IP openstack-ansible \ - $PLAYBOOK_PATH/setup-infrastructure.yml" | \ - tee $LOG_PATH/setup-infrastructure.log - -grep "failed=1" $LOG_PATH/setup-infrastructure.log>/dev/null \ - || grep "unreachable=1" $LOG_PATH/setup-infrastructure.log>/dev/null -if [ $? -eq 0 ]; then - echo "failed setup infrastructure!" - exit 1 -else - echo "setup infrastructure successfully!" -fi - -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 - -grep "FAILED" $LOG_PATH/galera.log>/dev/null -if [ $? -eq 0 ]; then - echo "failed verify the database cluster!" - exit 1 -else - echo "verify the database cluster successfully!" -fi - -echo "Set UP OpenStack !" -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/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 -else - echo "OpenStack successfully deployed!" - exit 0 -fi -- cgit 1.2.3-korg