-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Much like the `network.device`, we add support for both the Data Source and Resource. Since `network.device` is so complex, we're only implementing a subset of it. Also like the `network.device`, the documentation is less than ideal. It's separated into multiple pages. And each page is slightly different. Maybe there's just a different way to find all of this information? Branch: joneshf/add-support-for-network-interface Pull-Request: #109
- Loading branch information
Showing
8 changed files
with
700 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "openwrt_network_interface Data Source - openwrt" | ||
subcategory: "" | ||
description: |- | ||
A logic network. | ||
--- | ||
|
||
# openwrt_network_interface (Data Source) | ||
|
||
A logic network. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "openwrt_network_interface" "br_testing" { | ||
id = "testing" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `id` (String) Name of the section. This name is only used when interacting with UCI directly. | ||
|
||
### Read-Only | ||
|
||
- `auto` (Boolean) Specifies whether to bring up this interface on boot. | ||
- `device` (String) Name of the (physical or virtual) device. This name is what the device is known as in LuCI or the `name` field in Terraform. This is not the UCI config name. | ||
- `disabled` (Boolean) Disables this interface. | ||
- `dns` (List of String) DNS servers | ||
- `gateway` (String) Gateway of the interface | ||
- `ip6assign` (Number) Delegate a prefix of given length to this interface | ||
- `ipaddr` (String) IP address of the interface | ||
- `macaddr` (String) Override the MAC Address of this interface. | ||
- `mtu` (Number) Override the default MTU on this interface. | ||
- `netmask` (String) Netmask of the interface | ||
- `peerdns` (Boolean) Use DHCP-provided DNS servers. | ||
- `proto` (String) The protocol type of the interface. Currently, only "dhcp, and "static" are supported. | ||
- `reqaddress` (String) Behavior for requesting address. Can only be one of "force", "try", or "none". | ||
- `reqprefix` (String) Behavior for requesting prefixes. Currently, only "auto" is supported. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "openwrt_network_interface Resource - openwrt" | ||
subcategory: "" | ||
description: |- | ||
A logic network. | ||
--- | ||
|
||
# openwrt_network_interface (Resource) | ||
|
||
A logic network. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "openwrt_network_device" "br_testing" { | ||
id = "br_testing" | ||
name = "br-testing" | ||
ports = [ | ||
"eth0", | ||
"eth1", | ||
"eth2.20", | ||
] | ||
type = "bridge" | ||
} | ||
resource "openwrt_network_interface" "testing" { | ||
device = openwrt_network_device.br_testing.name | ||
dns = [ | ||
"9.9.9.9", | ||
"1.1.1.1", | ||
] | ||
id = "testing" | ||
ipaddr = "192.168.3.1" | ||
netmask = "255.255.255.0" | ||
proto = "static" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `device` (String) Name of the (physical or virtual) device. This name is what the device is known as in LuCI or the `name` field in Terraform. This is not the UCI config name. | ||
- `id` (String) Name of the section. This name is only used when interacting with UCI directly. | ||
- `proto` (String) The protocol type of the interface. Currently, only "dhcp, and "static" are supported. | ||
|
||
### Optional | ||
|
||
- `auto` (Boolean) Specifies whether to bring up this interface on boot. | ||
- `disabled` (Boolean) Disables this interface. | ||
- `dns` (List of String) DNS servers | ||
- `gateway` (String) Gateway of the interface | ||
- `ip6assign` (Number) Delegate a prefix of given length to this interface | ||
- `ipaddr` (String) IP address of the interface | ||
- `macaddr` (String) Override the MAC Address of this interface. | ||
- `mtu` (Number) Override the default MTU on this interface. | ||
- `netmask` (String) Netmask of the interface | ||
- `peerdns` (Boolean) Use DHCP-provided DNS servers. | ||
- `reqaddress` (String) Behavior for requesting address. Can only be one of "force", "try", or "none". | ||
- `reqprefix` (String) Behavior for requesting prefixes. Currently, only "auto" is supported. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# Find the Terraform id is the same as the UCI name from LuCI's JSON-RPC API. | ||
# It is also generally the lower-cased version of the interface name in LuCI's web UI. | ||
# One way to find this information is with `curl` and `jq`: | ||
# | ||
# curl \ | ||
# --data '{"id": 0, "method": "foreach", "params": ["network", "interface"]}' \ | ||
# http://192.168.1.1/cgi-bin/luci/rpc/uci?auth=$AUTH_TOKEN \ | ||
# | jq '.result | map(.[".name"])' | ||
# | ||
# This command will output something like: | ||
# | ||
# [ | ||
# "loopback", | ||
# "wan", | ||
# "wan6" | ||
# ] | ||
# | ||
# We'd then use the information to import the appropriate resource: | ||
|
||
terraform import openwrt_network_interface.loopback loopback | ||
``` |
3 changes: 3 additions & 0 deletions
3
examples/data-sources/openwrt_network_interface/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "openwrt_network_interface" "br_testing" { | ||
id = "testing" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Find the Terraform id is the same as the UCI name from LuCI's JSON-RPC API. | ||
# It is also generally the lower-cased version of the interface name in LuCI's web UI. | ||
# One way to find this information is with `curl` and `jq`: | ||
# | ||
# curl \ | ||
# --data '{"id": 0, "method": "foreach", "params": ["network", "interface"]}' \ | ||
# http://192.168.1.1/cgi-bin/luci/rpc/uci?auth=$AUTH_TOKEN \ | ||
# | jq '.result | map(.[".name"])' | ||
# | ||
# This command will output something like: | ||
# | ||
# [ | ||
# "loopback", | ||
# "wan", | ||
# "wan6" | ||
# ] | ||
# | ||
# We'd then use the information to import the appropriate resource: | ||
|
||
terraform import openwrt_network_interface.loopback loopback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
resource "openwrt_network_device" "br_testing" { | ||
id = "br_testing" | ||
name = "br-testing" | ||
ports = [ | ||
"eth0", | ||
"eth1", | ||
"eth2.20", | ||
] | ||
type = "bridge" | ||
} | ||
|
||
resource "openwrt_network_interface" "testing" { | ||
device = openwrt_network_device.br_testing.name | ||
dns = [ | ||
"9.9.9.9", | ||
"1.1.1.1", | ||
] | ||
id = "testing" | ||
ipaddr = "192.168.3.1" | ||
netmask = "255.255.255.0" | ||
proto = "static" | ||
} |
Oops, something went wrong.