Add example for users CSV
This commit is contained in:
35
README.md
35
README.md
@@ -4,7 +4,40 @@ This is very much WIP, just adding functionality as I need it for my local setup
|
||||
|
||||
**Note** You can't (for obvious reasons) configure your network while connected to something that may disconnect (like the WiFi). Use a hard-wired connection to your controller to use this provider.
|
||||
|
||||
## Example
|
||||
## Examples
|
||||
|
||||
### Clients (Users) with optional fixed IPs from CSV
|
||||
|
||||
```terraform
|
||||
locals {
|
||||
userscsv = csvdecode(file("${path.module}/users.csv"))
|
||||
users = { for user in local.userscsv : user.mac => user }
|
||||
}
|
||||
|
||||
resource "unifi_user" "user" {
|
||||
for_each = local.users
|
||||
|
||||
mac = each.key
|
||||
name = each.value.name
|
||||
# append an optional additional note
|
||||
note = trimspace("${each.value.note}\n\nmanaged by TF")
|
||||
|
||||
fixed_ip = each.value.fixed_ip
|
||||
# this assumes there is a unifi_network for_each with names
|
||||
network_id = each.value.network != "" ? unifi_network.vlan[each.value.network].id : ""
|
||||
|
||||
allow_existing = true
|
||||
skip_forget_on_destroy = true
|
||||
}
|
||||
```
|
||||
|
||||
```csv
|
||||
mac,name,note,network,fixed_ip
|
||||
00:00:00:00:00:00,My Device,custom note,,,
|
||||
00:00:00:00:00:00,My Device,custom note,network name to lookup,10.0.3.4
|
||||
```
|
||||
|
||||
### WIFI (WLAN) and Network for VLAN
|
||||
|
||||
This example sets up a WIFI SSID and VLAN with bandwidth throttling:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user