1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-14 12:12:12 +00:00

add in ansible vars, and network control files for network manager and systemd networkd

This commit is contained in:
George Hunt 2019-04-14 14:29:56 -07:00
parent 24d3d5c989
commit ec04e861c7
4 changed files with 158 additions and 87 deletions

View file

@ -1,85 +0,0 @@
#!/bin/bash
# if called w/ parameter, skip the reset, create diagnostic package w/ param as file name
SCRIPTDIR=$(cd `dirname $0` pwd)
diagnose_name=
if [ $# -ne 0 ]; then
basket=$1
diagnose_name=$1
else
basket=netlog.$$
fi
# collect all the network info in one place
mkdir -p /tmp/$basket
cat << EOF > /tmp/script2overview
#!/bin/bash
# generate the body overview part diagnostic package about network
echo "=========================================================="
echo iiab.env
cat /etc/iiab/iiab.env
echo "=========================================================="
echo ifconfig
ifconfig
echo
echo "=========================================================="
echo ip addr
ip addr
echo
echo "=========================================================="
echo "brctl show"
brctl show
echo
echo "=========================================================="
echo "/etc/resolv.conf"
cat /etc/resolv.conf
echo
echo "=========================================================="
echo "cat {{ iiab_ini_file }}"
cat {{ iiab_ini_file }}
echo
echo "=========================================================="
echo "routing table"
netstat -rn
echo
echo "=========================================================="
echo "install log -- last 50 lines"
tail -50 /opt/iiab/iiab/iiab-install.log
echo
echo "=========================================================="
echo "iiab-network log -- last 50 lines"
if [ -f /opt/iiab/iiab/iiab-network.log ]; then
tail -50 /opt/iiab/iiab/iiab-network.log
else
echo no iiab-network.log
fi
echo
echo "=========================================================="
EOF
chmod 755 /tmp/script2overview
/tmp/script2overview > /tmp/$basket/overview
if [ -f /opt/iiab/iiab/iiab-network.log ]; then
cp /opt/iiab/iiab/iiab-network.log /tmp/$basket
else
touch /tmp/$basket/no_iiab-network.log
fi
if [ -f /opt/iiab/iiab/iiab-network.log ]; then
cp -p /opt/iiab/iiab/iiab-network.log /tmp/$basket
fi
mkdir -p /etc/iiab/diagnose/
if [ ! -z $diagnose_name ];then
pushd /tmp > /dev/null
tar czf /etc/iiab/diagnose/$basket.tgz $basket/*
popd > /dev/null
rm -rf /tmp/$basket
exit 0
else
pushd /tmp > /dev/null
tar czf /etc/iiab/diagnose/$basket.tgz $basket/*
popd > /dev/null
rm -rf /tmp/$basket
fi
echo -e "\n\nAll Network variables erased. Now run 'iiab-network' to set up the new network configuration.\n\nPlease see /opt/iiab/iiab/docs/GETTING_HELP.rst for ways to get help or \nprovide the feedback which will improve IIAB\n\n"

View file

@ -0,0 +1,14 @@
- name: Print some debug information
vars:
msg: |
Module Variables ("vars"):
--------------------------------
{{ vars | to_nice_json }}
Environment Variables ("environment"):
--------------------------------
{{ environment | to_nice_json }}
debug:
msg: "{{ msg.split('\n') }}"
tags: debug_info

View file

@ -4,8 +4,11 @@ INVENTORY="ansible_hosts"
PLAYBOOK="run-one-role.yml"
#PLAYBOOK="iiab-stages.yml"
CWD=`pwd`
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
if [ $# -eq 2 ]; then
export ANSIBLE_LOG_PATH="$2"
else
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
fi
if [ ! -f $PLAYBOOK ]; then
echo "Exiting: IIAB Playbook not found."

139
scripts/net-footprint Executable file
View file

@ -0,0 +1,139 @@
#!/bin/bash
# create a diagnostic footprint of network, and OS settings
read -p "\n\nPlease identiy yourself (<8 characters, no spaces)" who
if [ -z "$who" ]; then
who="noname"
fi
read -p "\n\nIf this is a request for help, what email addr for response" email
# Build up a meaningful name for transmission back to the development team
OS_VER=`cat /etc/iiab/iiab.env | grep OS_VER | cut -d'=' -f2`
pushd /opt/iiab/iiab
HASH=`git log --pretty=format:'g%h' -n 1`
YMD=$(date +%y%m%d)
popd
SCRIPTDIR=$(cd `dirname $0` pwd)
footprint_name=${OS_VER}-$YMD-$who
basket=$footprint_name.$$
VARS_VALUES=/tmp/all-vars
# record all the ansible variables
pushd /opt/iiab/iiab > /dev/null
./runrole all-vars $VARS_VALUES
popd > /dev/null
# cat files in this direcory
function cat_dir(){
echo "=========================================================="
echo "Printing contents of $1"
filelist=$(ls $1)
if [ ! -z "$filelist" ]; then
pushd $1
for f in `ls *`;do
echo $f
cat $f
done
popd
fi
}
# collect all the network info in one place
mkdir -p /tmp/$basket
cat << EOF > /tmp/script2overview
#!/bin/bash
# generate the body overview part diagnostic package about network
echo "=========================================================="
echo Footprint submitted by:
echo $who
echo $email
echo "=========================================================="
echo iiab.env
cat /etc/iiab/iiab.env
echo "=========================================================="
echo ifconfig
ifconfig
echo
echo "=========================================================="
echo ip addr
ip addr
echo
echo "=========================================================="
echo "brctl show"
brctl show
echo
echo "=========================================================="
echo "/etc/resolv.conf"
cat /etc/resolv.conf
echo
echo "=========================================================="
echo "cat iiab_ini_file "
cat /etc/iiab/iiab.ini
echo
echo "=========================================================="
echo "routing table"
netstat -rn
echo
echo "=========================================================="
echo "install log -- last 50 lines"
tail -50 /opt/iiab/iiab/iiab-install.log
echo
echo "=========================================================="
echo "iiab-network log -- last 50 lines"
if [ -f /opt/iiab/iiab/iiab-network.log ]; then
tail -50 /opt/iiab/iiab/iiab-network.log
else
echo no iiab-network.log
fi
echo
echo "=========================================================="
echo "Contents of /etc/network/interfaces"
cat /etc/network/interfaces
echo "End of Contents of /etc/network/interfaces"
echo "=========================================================="
# cat files in this direcory
function cat_dir(){
echo "=========================================================="
echo "Printing contents of Directory \$1"
filelist=\$(ls \$1)
if [ ! -z "\$filelist" ]; then
for f in \$filelist;do
echo ===== Contents of file: \$base/\$f
cat \$1/\$f
echo ===== End of Contents of file: \$f
done
fi
}
cat_dir /etc/network/interfaces.d
cat_dir /etc/systemd/network
cat_dir /etc/NetworkManager/system-connections
cat_dir /etc/sysconfig/network-scripts/if-cfg*
EOF
chmod 755 /tmp/script2overview
/tmp/script2overview > /tmp/$basket/overview
if [ -f /opt/iiab/iiab/iiab-debug.log ]; then
cp /opt/iiab/iiab/iiab-debug.log /tmp/$basket
else
touch /tmp/$basket/no_iiab-network.log
fi
if [ -f /opt/iiab/iiab/iiab-install.log ]; then
cp -p /opt/iiab/iiab/iiab-install.log /tmp/$basket
fi
if [ -f "$VARS_VALUES" ]; then
cp -p "$VARS_VALUES" /tmp/$basket
fi
mkdir -p /etc/iiab/footprint
if [ ! -z $footprint_name ];then
pushd /tmp > /dev/null
tar czf /etc/iiab/footprint/$basket.tgz $basket/*
popd > /dev/null
rm -rf /tmp/$basket
exit 0
fi
cat_dir /etc/interfaces.d
cat_dir /etc/systemd/network