Skip to content

Instantly share code, notes, and snippets.

@tcoupin
Created October 15, 2017 14:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcoupin/c8a735b6eab83fa41a104d919dc49e88 to your computer and use it in GitHub Desktop.
Save tcoupin/c8a735b6eab83fa41a104d919dc49e88 to your computer and use it in GitHub Desktop.
Setup wifi with cloud-init on Rpi3
write_files:
- content: |
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
path: /etc/network/interfaces.d/wlan0
- content: |
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="MY_SSID"
psk="MY_PASSWORD"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
path: /etc/wpa_supplicant/wpa_supplicant.conf
power_state:
delay: now
mode: reboot
condition: true
@tcoupin
Copy link
Author

tcoupin commented Oct 15, 2017

Why is it so $&#*$ !!? Because:

  • cloud-init is not design for wifi configuration
  • User-data cannot change an instance’s network configuration. In the absence of network configuration in any of the above sources , Cloud-init will write out a network configuration that will issue a DHCP request on a “first” network interface.

  • it is sunday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment