Fix some issues in examples so they run
This commit is contained in:
@@ -10,9 +10,8 @@ description: |-
|
|||||||
Given a CSV file with the following content:
|
Given a CSV file with the following content:
|
||||||
|
|
||||||
```csv
|
```csv
|
||||||
mac,name,note,network,fixed_ip
|
mac,name,note
|
||||||
00:00:00:00:00:00,My Device,custom note,,,
|
01:23:45:67:89:AB,My Device,custom note
|
||||||
00:00:00:00:00:00,My Device,custom note,network name to lookup,10.0.3.4
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You could create/manage a `unifi_user` for every row/MAC address in the CSV with the following config:
|
You could create/manage a `unifi_user` for every row/MAC address in the CSV with the following config:
|
||||||
@@ -31,10 +30,6 @@ resource "unifi_user" "user" {
|
|||||||
# append an optional additional note
|
# append an optional additional note
|
||||||
note = trimspace("${each.value.note}\n\nmanaged by TF")
|
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
|
allow_existing = true
|
||||||
skip_forget_on_destroy = true
|
skip_forget_on_destroy = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ provider "unifi" {
|
|||||||
password = var.password # optionally use UNIFI_PASSWORD env var
|
password = var.password # optionally use UNIFI_PASSWORD env var
|
||||||
api_url = var.api_url # optionally use UNIFI_API env var
|
api_url = var.api_url # optionally use UNIFI_API env var
|
||||||
|
|
||||||
|
# you may need to allow insecure TLS communications unless you have configured
|
||||||
|
# certificates for your controller
|
||||||
|
allow_insecure = var.insecure # optionally use UNIFI_INSECURE env var
|
||||||
|
|
||||||
# if you are not configuring the default site, you can change the site
|
# if you are not configuring the default site, you can change the site
|
||||||
# site = "foo" or optionally use UNIFI_SITE env var
|
# site = "foo" or optionally use UNIFI_SITE env var
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ resource "unifi_user" "test" {
|
|||||||
name = "some client"
|
name = "some client"
|
||||||
note = "my note"
|
note = "my note"
|
||||||
|
|
||||||
fixed_ip = "10.1.10.50"
|
fixed_ip = "10.0.0.50"
|
||||||
network_id = unifi_network.my_vlan.id
|
network_id = unifi_network.my_vlan.id
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
mac,name,note,network,fixed_ip
|
mac,name,note
|
||||||
00:00:00:00:00:00,My Device,custom note,,,
|
01:23:45:67:89:AB,My Device,custom note
|
||||||
00:00:00:00:00:00,My Device,custom note,network name to lookup,10.0.3.4
|
|
||||||
|
|||||||
|
@@ -11,10 +11,6 @@ resource "unifi_user" "user" {
|
|||||||
# append an optional additional note
|
# append an optional additional note
|
||||||
note = trimspace("${each.value.note}\n\nmanaged by TF")
|
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
|
allow_existing = true
|
||||||
skip_forget_on_destroy = true
|
skip_forget_on_destroy = true
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,10 @@ provider "unifi" {
|
|||||||
password = var.password # optionally use UNIFI_PASSWORD env var
|
password = var.password # optionally use UNIFI_PASSWORD env var
|
||||||
api_url = var.api_url # optionally use UNIFI_API env var
|
api_url = var.api_url # optionally use UNIFI_API env var
|
||||||
|
|
||||||
|
# you may need to allow insecure TLS communications unless you have configured
|
||||||
|
# certificates for your controller
|
||||||
|
allow_insecure = var.insecure # optionally use UNIFI_INSECURE env var
|
||||||
|
|
||||||
# if you are not configuring the default site, you can change the site
|
# if you are not configuring the default site, you can change the site
|
||||||
# site = "foo" or optionally use UNIFI_SITE env var
|
# site = "foo" or optionally use UNIFI_SITE env var
|
||||||
}
|
}
|
||||||
6
examples/provider/test.auto.tfvars
Normal file
6
examples/provider/test.auto.tfvars
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
username = "tfacctest"
|
||||||
|
password = "tfacctest1234"
|
||||||
|
|
||||||
|
# this assumes the default port for acc testing
|
||||||
|
api_url = "https://localhost:8443/api/"
|
||||||
|
insecure = true
|
||||||
@@ -5,4 +5,8 @@ variable "password" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
variable "api_url" {
|
variable "api_url" {
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "insecure" {
|
||||||
|
default = false
|
||||||
}
|
}
|
||||||
2
examples/resources/unifi_firewall_group/test.auto.tfvars
Normal file
2
examples/resources/unifi_firewall_group/test.auto.tfvars
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# these values are used in tests
|
||||||
|
laptop_ips = ["192.168.1.25"]
|
||||||
2
examples/resources/unifi_firewall_rule/test.auto.tfvars
Normal file
2
examples/resources/unifi_firewall_rule/test.auto.tfvars
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# these values are used in tests
|
||||||
|
ip_address = "192.168.1.1"
|
||||||
1
examples/resources/unifi_network/test.auto.tfvars
Normal file
1
examples/resources/unifi_network/test.auto.tfvars
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vlan_id = 41
|
||||||
@@ -3,6 +3,6 @@ resource "unifi_user" "test" {
|
|||||||
name = "some client"
|
name = "some client"
|
||||||
note = "my note"
|
note = "my note"
|
||||||
|
|
||||||
fixed_ip = "10.1.10.50"
|
fixed_ip = "10.0.0.50"
|
||||||
network_id = unifi_network.my_vlan.id
|
network_id = unifi_network.my_vlan.id
|
||||||
}
|
}
|
||||||
1
examples/resources/unifi_user/test.auto.tfvars
Normal file
1
examples/resources/unifi_user/test.auto.tfvars
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vlan_id = 42
|
||||||
Reference in New Issue
Block a user