Skip to content

Instantly share code, notes, and snippets.

@samos123
Created March 24, 2018 03:45
Show Gist options
  • Save samos123/380e29e0c0aa9ec37af53dcf76e92aff to your computer and use it in GitHub Desktop.
Save samos123/380e29e0c0aa9ec37af53dcf76e92aff to your computer and use it in GitHub Desktop.
#!/bin/bash
set -xe
while read host; do
echo "Setting correct dhcp network setting for $host"
ip=$(reclass-salt --pillar $host | grep single_address | grep -Eo "([0-9\.]*)$")
ssh $ip << EOF
if ! grep -q "ens2 inet dhcp" /etc/network/interfaces; then
cat << EOT >> /etc/network/interfaces
auto ens2
iface ens2 inet dhcp
EOT
fi
ifup ens2
EOF
done < down-nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment