サーバーの /etc/hosts
を更新して、ホスト名で追加したサーバーへ疎通がとれるようにする
for i in $(grep <!-- 更新対象サーバー --> /etc/hosts | awk -F" " '{print $1}') ; do echo -e "\n$i" ssh -t $i "grep <!-- 削除するホスト --> <!-- application の conf -->" ; done
for i in $(grep <!-- 更新対象サーバー --> /etc/hosts | awk -F" " '{print $1}') ; do echo -e "\n$i" ssh -t $i "ping <!-- 追加するサーバーのIP -->" ; done
tmp_etc_hosts
という名前で用意するfor i in $(grep <!-- 更新対象サーバー --> /etc/hosts | awk -F" " '{print $1}') ; do scp tmp_etc_hosts $i:/tmp/ ; echo -e "\n$i"; ssh -t $i "sudo cp /tmp/tmp_etc_hosts /etc/hosts ;" ; done
for i in $(grep <!-- 更新対象サーバー --> /etc/hosts | awk -F" " '{print $1}') ; do echo -e "\n$i" ssh -t $i "ping <!-- 追加した host -->" ; done
ウェブ界隈でエンジニアとして労働活動に励んでいる @gomi_ningen 個人のブログです