Added option to skip running ansible build and removed unnecessary if statement

This commit is contained in:
Beth Parker 2025-03-29 16:59:44 -05:00
parent d9a53be2c5
commit 7f6a7571d9

View file

@ -13,6 +13,7 @@ dhcp_dir="../../dhcp_files"
mac=52:54:00:`openssl rand -hex 1`:`openssl rand -hex 1`:`openssl rand -hex 1` mac=52:54:00:`openssl rand -hex 1`:`openssl rand -hex 1`:`openssl rand -hex 1`
branch="prod" branch="prod"
deflate="y" deflate="y"
ansible="y"
#get variables #get variables
numre='^[0-9]+$' numre='^[0-9]+$'
@ -36,6 +37,7 @@ while true; do read -p "Specify last segment of IP (defaults to next available):
while true; do read -p "Specify branch of build_ansible to use (defult $branch): " v;if [ -z $v ]; then break;else branch=$v;break;fi;done while true; do read -p "Specify branch of build_ansible to use (defult $branch): " v;if [ -z $v ]; then break;else branch=$v;break;fi;done
while true; do read -p "Full path to extra disk to attach (if applicable, default none): " v;if [ -z $v ]; then break;else if ! [ -f $v ] ; then echo "error: file doesn't exist";else attach=$v;break;fi;fi;done while true; do read -p "Full path to extra disk to attach (if applicable, default none): " v;if [ -z $v ]; then break;else if ! [ -f $v ] ; then echo "error: file doesn't exist";else attach=$v;break;fi;fi;done
while true; do read -p "Autodeflate memory on use y/n (default $deflate)? " v;if [ -z $v ]; then break;elif [ "$v" == "y" ];then break; elif [ "$v" == "n" ];then deflate=$v;break;else echo "error: select y or n";fi;done while true; do read -p "Autodeflate memory on use y/n (default $deflate)? " v;if [ -z $v ]; then break;elif [ "$v" == "y" ];then break; elif [ "$v" == "n" ];then deflate=$v;break;else echo "error: select y or n";fi;done
while true; do read -p "Autorun ansible build script (default $ansible)? " v;if [ -z $v ]; then break;elif [ "$v" == "y" ];then break; elif [ "$v" == "n" ];then ansible=$v;break;else echo "error: select y or n";fi;done
echo "" echo ""
echo "Name: $name" echo "Name: $name"
@ -50,6 +52,7 @@ echo "IP: $ip"
echo "Branch: $branch" echo "Branch: $branch"
echo "Attach: $attach" echo "Attach: $attach"
echo "Deflate: $deflate" echo "Deflate: $deflate"
echo "Run Ansible: $ansible"
echo "" echo ""
read -p "Is this correct (y/n)? " v;if [ "$v" != "y" ];then "Exiting, restart to reenter info"; exit;fi read -p "Is this correct (y/n)? " v;if [ "$v" != "y" ];then "Exiting, restart to reenter info"; exit;fi
@ -59,8 +62,6 @@ if [ -n $ip ]; then dhcp_opts+=" -i $ip";fi
lname=`echo $name | tr '[:upper:]' '[:lower:]'` lname=`echo $name | tr '[:upper:]' '[:lower:]'`
if [[ "$path" -eq "default" ]];then path=/virtual/disks/${name}.qcow2;fi
img=`./shared_scripts/download_install_image.sh $variant` img=`./shared_scripts/download_install_image.sh $variant`
#update DHCP #update DHCP
@ -166,7 +167,9 @@ ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "ansible-galaxy collecti
# run ansible # run ansible
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "mkdir /ansible/; curl -k 'https://git.actcur.com/actcur-ansible/playbook-builder/raw/branch/$branch/build_ansible.sh' -H 'accept: application/raw' -o /ansible/build_ansible.sh;echo "$branch" > /ansible/branch;/bin/bash /ansible/build_ansible.sh" ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "mkdir /ansible/; curl -k 'https://git.actcur.com/actcur-ansible/playbook-builder/raw/branch/$branch/build_ansible.sh' -H 'accept: application/raw' -o /ansible/build_ansible.sh;echo "$branch" > /ansible/branch;/bin/bash /ansible/build_ansible.sh"
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "/bin/bash /ansible/build_ansible.sh" if [[ "$deflate" == "y" ]]; then
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "/bin/bash /ansible/build_ansible.sh"
fi
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "git config --global user.email 'ejparker@actcur.com';git config --global user.name 'Beth Parker'" ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "git config --global user.email 'ejparker@actcur.com';git config --global user.name 'Beth Parker'"