There is an included playbook (inside setup/networking
) which will set up all the Pi networking configuration following the below network layout:
kube1.pidramble.com
(10.0.1.61)kube2.pidramble.com
(10.0.1.62)kube3.pidramble.com
(10.0.1.63)kube4.pidramble.com
(10.0.1.64)
To use it, you will need to know the IP addresses and MAC addresses for all four Pis as they are currently set up. Copy example.vars.yml
to vars.yml
, and example.inventory
to inventory
. Map each MAC address to the new structures inside the networking vars.yml
, and add all the current Pi IP addresses under the [pis]
group inside the networking inventory
file. Then run (within the setup/networking
directory):
$ ansible-playbook -i inventory main.yml
Assuming everything went well, the Pis should switch over to their new IP addresses quickly; if they don't, you can forcefully reboot them with the command:
$ ansible all -i inventory -m shell -a "sleep 1s; shutdown -r now" -b -B 60 -P 0
This rather complex command has a few extra flags and options to tell Ansible to ignore the result (since shutting down the server would drop the connection and throw an error!), and sends a command to the server to 'sleep 1 second, then shut down with reboot'.
Once the Pis have their new IP addresses, you should be able to follow the next steps to set up the Pis.
This networking configuration works for me and my local network setup. If you’d like to adjust the private network range used, or the IP addresses, etc., you’ll need to do that on your own :)
General Networking Information
Generally speaking, networking setup is done via /etc/network/interfaces
, and WiFi specific configuration in /etc/wpa_supplicant/wpa_supplicant.conf
.
Setting up WiFi
See: Setting up the Edimax EW-7811Un or Tenda W311Mi 802.11b/g/n WiFi Adapter on a Raspberry Pi.
Gigabit Networking
See: Getting Gigabit Networking on a Raspberry Pi 2/3 and B+.
Switching Network Interfaces
When switching network interfaces, you should follow the process below to make sure you can connect over the new network interface and it has its routing configured correctly:
- Log into the interface you want to test (e.g. IP .35 for Wifi, .36 for Ethernet, in my case).
$ sudo ifdown [eth0|wlan0]
(whichever one you are not connected through).$ sudo ifconfig -a
to list all interfaces and verify current status.$ ping 8.8.8.8
to test Internet connectivity, and if it’s down:$ ip route show
to make sure there’s adefault
route configured.- If not,
$ sudo ip route add default via 10.0.1.1 dev [eth0|wlan0]
(whichever one you are connected through). $ ping 8.8.8.8
again to test Internet connectivity.
- Profit!