#!/bin/bash
##
## https://docs.google.com/spreadsheets/d/1wF6KZuathGsVSCCoEC5l_GBcLZLcrjMTARH0Ak99HdE/edit?gid=169529108#gid=169529108
##
## gateway:   ip route | grep default | awk '{print $3}'


if [[ "$#" <  4 ]]; then
  
  echo "$0 FQDN  NetworkDeviceName  CIDR GateWay"
  echo "$0 centostwo.binghamton.edu enp0s31f6 128.226.31.101/24   128.226.30.1"

else

   Server=${1}
   NicName=${2}
   CIDR=${3}
   NewGW=$4

   echo " "
   echo "echo \"### ${Server} ### \""
   echo "ansible ${Server} -m raw -a \"nmcli con mod ${NicName} ipv4.addresses ${CIDR}\""
   echo "ansible ${Server} -m raw -a \"nmcli con mod ${NicName} ipv4.gateway ${NewGW}\""
   echo "ansible ${Server} -m raw -a \"nmcli con mod ${NicName} ipv4.method manual\""
   echo "ansible ${Server} -m raw -a \"nmcli con up  ${NicName}\""

fi
