Reduce script verbosity

Currently the verbose shell builtin is used, resulting in the entire
scripts contents being output in the logs. The instance information is
also output to stdout. This is unnecessarily verbose and prone to
failure. To ensure that the instance information is correctly rendered
failures from within the instance information commands will now always
return true and be logged within the `/openstack/log/ansible-logging`
directory. Each time that the function is called a new log will be
created tagged with the datecode in seconds. This commit also removes
the verbose builtin from the scripts, removes the unused
os-ansible-aio-check script.

Partial-Bug: #1425482
Change-Id: I59952d077a1a8dda12278e57a165d4bac272ed5f
This commit is contained in:
Jesse Pretorius 2015-03-13 12:51:24 +00:00 committed by Kevin Carter
parent af64fa9f1f
commit f611600fd4
9 changed files with 42 additions and 41 deletions

View File

@ -15,7 +15,7 @@
# limitations under the License. # limitations under the License.
## Shell Opts ---------------------------------------------------------------- ## Shell Opts ----------------------------------------------------------------
set -e -u -v -x set -e -u -x
## Vars ---------------------------------------------------------------------- ## Vars ----------------------------------------------------------------------
@ -55,6 +55,9 @@ if ! [ -d $SYMLINK_DIR ] ; then
exit_fail exit_fail
fi fi
# Log some data about the instance and the rest of the system
log_instance_info
# Ensure that the current kernel can support vxlan # Ensure that the current kernel can support vxlan
if ! modprobe vxlan; then if ! modprobe vxlan; then
MINIMUM_KERNEL_VERSION=$(awk '/openstack_host_required_kernel/ {print $2}' playbooks/inventory/group_vars/all.yml) MINIMUM_KERNEL_VERSION=$(awk '/openstack_host_required_kernel/ {print $2}' playbooks/inventory/group_vars/all.yml)
@ -265,5 +268,7 @@ if [ "${DEPLOY_SWIFT}" == "yes" ]; then
sed -i "s/glance_swift_store_user:.*/glance_swift_store_user: '{{ keystone_admin_user_name }}:{{ keystone_admin_tenant_name }}'/" /etc/openstack_deploy/user_secrets.yml sed -i "s/glance_swift_store_user:.*/glance_swift_store_user: '{{ keystone_admin_user_name }}:{{ keystone_admin_tenant_name }}'/" /etc/openstack_deploy/user_secrets.yml
fi fi
set +x +v # Log some data about the instance and the rest of the system
log_instance_info
info_block "The system has been prepared for an all-in-one build." info_block "The system has been prepared for an all-in-one build."

View File

@ -16,7 +16,7 @@
# (c) 2014, Kevin Carter <kevin.carter@rackspace.com> # (c) 2014, Kevin Carter <kevin.carter@rackspace.com>
## Shell Opts ---------------------------------------------------------------- ## Shell Opts ----------------------------------------------------------------
set -e -u -v -x set -e -u -x
## Vars ---------------------------------------------------------------------- ## Vars ----------------------------------------------------------------------

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
## Shell Opts ---------------------------------------------------------------- ## Shell Opts ----------------------------------------------------------------
set -e -u -v +x set -e -u +x
## Variables ----------------------------------------------------------------- ## Variables -----------------------------------------------------------------
export ANSIBLE_DISABLE_COLOR=${ANSIBLE_DISABLE_COLOR:-"yes"} export ANSIBLE_DISABLE_COLOR=${ANSIBLE_DISABLE_COLOR:-"yes"}
@ -48,8 +48,6 @@ export TESTR_OPTS=${TESTR_OPTS:-''}
info_block "Checking for required libraries." 2> /dev/null || source $(dirname ${0})/scripts-library.sh info_block "Checking for required libraries." 2> /dev/null || source $(dirname ${0})/scripts-library.sh
## Main ---------------------------------------------------------------------- ## Main ----------------------------------------------------------------------
# Get initial host information and reset verbosity
set +x && get_instance_info && set -x
# Remove color options # Remove color options
if [ "${ANSIBLE_DISABLE_COLOR}" == "yes" ]; then if [ "${ANSIBLE_DISABLE_COLOR}" == "yes" ]; then
@ -68,9 +66,6 @@ if [ "${BOOTSTRAP_ANSIBLE}" == "yes" ]; then
source $(dirname ${0})/bootstrap-ansible.sh source $(dirname ${0})/bootstrap-ansible.sh
fi fi
# Get initial host information and reset verbosity
set +x && get_instance_info && set -x
# Run the ansible playbooks if required # Run the ansible playbooks if required
if [ "${RUN_PLAYBOOKS}" == "yes" ]; then if [ "${RUN_PLAYBOOKS}" == "yes" ]; then
# Set-up our tiny awk script. # Set-up our tiny awk script.

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
## Shell Opts ---------------------------------------------------------------- ## Shell Opts ----------------------------------------------------------------
set -e -u -v -x set -e -u -x
## Library Check ------------------------------------------------------------- ## Library Check -------------------------------------------------------------

View File

@ -1,9 +0,0 @@
#!/bin/bash
# This is a placeholder until we change the macro for the
# os-ansible-deployment gate check script to use the
# newly split script set.
set -e -u -v -x
source $(dirname ${0})/gate-check-commit.sh

View File

@ -15,7 +15,7 @@
## Shell Opts ---------------------------------------------------------------- ## Shell Opts ----------------------------------------------------------------
set -e -u -v +x set -e -u +x
## Variables ----------------------------------------------------------------- ## Variables -----------------------------------------------------------------
export REPO_URL=${REPO_URL:-"https://github.com/stackforge/os-ansible-deployment.git"} export REPO_URL=${REPO_URL:-"https://github.com/stackforge/os-ansible-deployment.git"}

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
## Shell Opts ---------------------------------------------------------------- ## Shell Opts ----------------------------------------------------------------
set -e -u -v -x set -e -u -x
## Variables ----------------------------------------------------------------- ## Variables -----------------------------------------------------------------
@ -57,8 +57,8 @@ pushd "playbooks"
# This is good when using a host with multiple times, IE: Rebuilding. # This is good when using a host with multiple times, IE: Rebuilding.
ansible hosts -m shell -a 'lxc-system-manage flush-net-cache' ansible hosts -m shell -a 'lxc-system-manage flush-net-cache'
# Get host information post initial setup and reset verbosity # Log some data about the instance and the rest of the system
set +x && get_instance_info && set -x log_instance_info
fi fi
if [ "${DEPLOY_LB}" == "yes" ]; then if [ "${DEPLOY_LB}" == "yes" ]; then

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
## Shell Opts ---------------------------------------------------------------- ## Shell Opts ----------------------------------------------------------------
set -e -u -v +x set -e -u +x
## Vars ---------------------------------------------------------------------- ## Vars ----------------------------------------------------------------------

View File

@ -204,19 +204,29 @@ function info_block(){
echo "${LINE}" echo "${LINE}"
} }
function log_instance_info() {
set +x
# Get host information post initial setup and reset verbosity
if [ ! -d "/openstack/log/instance-info" ];then
mkdir -p "/openstack/log/instance-info"
fi
get_instance_info &> /openstack/log/instance-info/host_info_$(date +%s).log
set -x
}
# Get instance info # Get instance info
function get_instance_info() { function get_instance_info() {
set +x set +x
info_block 'Available Memory' info_block 'Available Memory'
free -mt free -mt || true
info_block 'Available Disk Space' info_block 'Available Disk Space'
df -h df -h || true
info_block 'Mounted Devices' info_block 'Mounted Devices'
mount mount || true
info_block 'Block Devices' info_block 'Block Devices'
lsblk lsblk || true
info_block 'Block Devices Information' info_block 'Block Devices Information'
blkid blkid || true
info_block 'Block Device Partitions' info_block 'Block Device Partitions'
for i in /dev/xv* /dev/sd* /dev/vd*; do for i in /dev/xv* /dev/sd* /dev/vd*; do
if [ -b "$i" ];then if [ -b "$i" ];then
@ -224,27 +234,27 @@ function get_instance_info() {
fi fi
done done
info_block 'PV Information' info_block 'PV Information'
pvs pvs || true
info_block 'VG Information' info_block 'VG Information'
vgs vgs || true
info_block 'LV Information' info_block 'LV Information'
lvs lvs || true
info_block 'CPU Information' info_block 'CPU Information'
which lscpu && lscpu which lscpu && lscpu || true
info_block 'Kernel Information' info_block 'Kernel Information'
uname -a uname -a || true
info_block 'Container Information' info_block 'Container Information'
which lxc-ls && lxc-ls --fancy which lxc-ls && lxc-ls --fancy || true
info_block 'Firewall Information' info_block 'Firewall Information'
iptables -vnL iptables -vnL || true
iptables -t nat -vnL iptables -t nat -vnL || true
iptables -t mangle -vnL iptables -t mangle -vnL || true
info_block 'Network Devices' info_block 'Network Devices'
ip a ip a || true
info_block 'Network Routes' info_block 'Network Routes'
ip r ip r || true
info_block 'Trace Path from google' info_block 'Trace Path from google'
tracepath 8.8.8.8 -m 5 tracepath 8.8.8.8 -m 5 || true
info_block 'XEN Server Information' info_block 'XEN Server Information'
if (which xenstore-read);then if (which xenstore-read);then
xenstore-read vm-data/provider_data/provider || echo "\nxenstore Read Failed - Skipping\n" xenstore-read vm-data/provider_data/provider || echo "\nxenstore Read Failed - Skipping\n"