Ansible playbook for Access Point setup and configuration on Raspberry Pi.
Does the following:
- Installs and configures
isc-dhcp-server. - Installs and configures
hostapd. - Installs and configures
iptables-persistent(for now needs a reboot to load the iptables kernel modules).
It is assumed that the Raspberry Pi 3 or later (with built in broadcom wifi adapter) is used with additional Ralink usb wifi dongle. It may also work with other RPI models, but just was not tested.
The one I use it with is Ralink USB WiFi RT5370:
- 802.11 b/g/n 150Mbps;
- 2.400-2.487 GHz channels 1-14;
- Power: Voltage: 5V+5%, Amperage: 70mA Average)
NOTE: Role requires Fact Gathering by ansible!
Debian-like linux distro installed
| Variable | Description | Default |
|---|---|---|
vault_rpi_wifi_ap_essid |
The Access Point ESSID | set your own in vars/vault.yml |
vault_rpi_wifi_ap_passphrase |
The Access Point WPA/WPA2 passphrase | set your own in vars/vault.yml |
vault_rpi_wifi_ap__rpi_network_wifi_APs |
The list of wifi networks to be configured on the system using the rpi_network role | set your own in vars/vault.yml, please check drew1kun.rpi_network/defaults/main.yaml for reference |
Install it with requirements.yml:
ansible-galaxy install -r requirements.yml --force
Or directly via ansible-galaxy:
ansible-galaxy install \
drew1kun.rpi_network \
drew1kun.rpi_wifi_ap
ATTENTION! Variables are set in vars/vault.yml,
which is encrypted with ansible-vault.
Therefore, there are multiple options to run the play available:
add the following to ansible.cfg:
[defaults]
vault_password_file = ./vault.key
Modify the vars/vault.yml as you wish using:
ansible-vault edit vars/vault.yml
Then run play as follows:
ansible-playbook --user user -k rpi_wifi_ap_playbook.yml
Before running the role decrypt the file vars/vault.yml with:
ansible-vault decrypt vars/main.yml --vault-password-file=vault.key
Then run play:
ansible-playbook -u user -k rpi_wifi_ap_playbook.yml
Set environment variable:
export ANSIBLE_VAULT_PASSWORD_FILE=vault.key
Then run play:
ansible-playbook -u user -k rpi_wifi_ap_playbook.yml
Just put the .vault.key to the playbook dir and run play:
ansible-playbook -u user \
-k rpi_wifi_ap_playbook.yml \
--vault-password-file=vault.key
Andrew Shagayev | e-mail