-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving on to DHCP stuff, we want to be able to configure the Dnsmasq stuff. As with all of the other resources we add, this is only a subset of what's available. We'll flesh out more as time goes on. Branch: joneshf/add-support-for-dhcp-dnsmasq Pull-Request: #127
- Loading branch information
Showing
9 changed files
with
557 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,44 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "openwrt_dhcp_dnsmasq Data Source - openwrt" | ||
subcategory: "" | ||
description: |- | ||
A lightweight DHCP and caching DNS server. | ||
--- | ||
|
||
# openwrt_dhcp_dnsmasq (Data Source) | ||
|
||
A lightweight DHCP and caching DNS server. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "openwrt_dhcp_dnsmasq" "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 | ||
|
||
- `authoritative` (Boolean) Force dnsmasq into authoritative mode. This speeds up DHCP leasing. Used if this is the only server on the network. | ||
- `domain` (String) DNS domain handed out to DHCP clients. | ||
- `domainneeded` (Boolean) Never forward queries for plain names, without dots or domain parts, to upstream nameservers. | ||
- `ednspacket_max` (Number) Specify the largest EDNS.0 UDP packet which is supported by the DNS forwarder. | ||
- `expandhosts` (Boolean) Never forward queries for plain names, without dots or domain parts, to upstream nameservers. | ||
- `leasefile` (String) Store DHCP leases in this file. | ||
- `local` (String) Look up DNS entries for this domain from `/etc/hosts`. | ||
- `localise_queries` (Boolean) Choose IP address to match the incoming interface if multiple addresses are assigned to a host name in `/etc/hosts`. | ||
- `localservice` (Boolean) Accept DNS queries only from hosts whose address is on a local subnet. | ||
- `readethers` (Boolean) Read static lease entries from `/etc/ethers`, re-read on SIGHUP. | ||
- `rebind_localhost` (Boolean) Allows upstream 127.0.0.0/8 responses, required for DNS based blocklist services. Only takes effect if rebind protection is enabled. | ||
- `rebind_protection` (Boolean) Enables DNS rebind attack protection by discarding upstream RFC1918 responses. | ||
- `resolvfile` (String) Specifies an alternative resolv file. | ||
|
||
|
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,73 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "openwrt_dhcp_dnsmasq Resource - openwrt" | ||
subcategory: "" | ||
description: |- | ||
A lightweight DHCP and caching DNS server. | ||
--- | ||
|
||
# openwrt_dhcp_dnsmasq (Resource) | ||
|
||
A lightweight DHCP and caching DNS server. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "openwrt_dhcp_dnsmasq" "this" { | ||
domain = "testing" | ||
expandhosts = true | ||
id = "testing" | ||
local = "/testing/" | ||
rebind_localhost = true | ||
rebind_protection = true | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `id` (String) Name of the section. This name is only used when interacting with UCI directly. | ||
|
||
### Optional | ||
|
||
- `authoritative` (Boolean) Force dnsmasq into authoritative mode. This speeds up DHCP leasing. Used if this is the only server on the network. | ||
- `domain` (String) DNS domain handed out to DHCP clients. | ||
- `domainneeded` (Boolean) Never forward queries for plain names, without dots or domain parts, to upstream nameservers. | ||
- `ednspacket_max` (Number) Specify the largest EDNS.0 UDP packet which is supported by the DNS forwarder. | ||
- `expandhosts` (Boolean) Never forward queries for plain names, without dots or domain parts, to upstream nameservers. | ||
- `leasefile` (String) Store DHCP leases in this file. | ||
- `local` (String) Look up DNS entries for this domain from `/etc/hosts`. | ||
- `localise_queries` (Boolean) Choose IP address to match the incoming interface if multiple addresses are assigned to a host name in `/etc/hosts`. | ||
- `localservice` (Boolean) Accept DNS queries only from hosts whose address is on a local subnet. | ||
- `readethers` (Boolean) Read static lease entries from `/etc/ethers`, re-read on SIGHUP. | ||
- `rebind_localhost` (Boolean) Allows upstream 127.0.0.0/8 responses, required for DNS based blocklist services. Only takes effect if rebind protection is enabled. | ||
- `rebind_protection` (Boolean) Enables DNS rebind attack protection by discarding upstream RFC1918 responses. | ||
- `resolvfile` (String) Specifies an alternative resolv file. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# Find the Terraform id from LuCI's JSON-RPC API. | ||
# One way to find this information is with `curl` and `jq`: | ||
# | ||
# curl \ | ||
# --data '{"id": 0, "method": "foreach", "params": ["dhcp", "dnsmasq"]}' \ | ||
# http://192.168.1.1/cgi-bin/luci/rpc/uci?auth=$AUTH_TOKEN \ | ||
# | jq '.result | map({terraformId: .[".name"]})' | ||
# | ||
# This command will output something like: | ||
# | ||
# [ | ||
# { | ||
# "terraformId": "cfg123456", | ||
# } | ||
# ] | ||
# | ||
# We'd then use the information to import the appropriate resource: | ||
|
||
terraform import openwrt_dhcp_dnsmasq.this cfg123456 | ||
``` |
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_dhcp_dnsmasq" "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,19 @@ | ||
# Find the Terraform id from LuCI's JSON-RPC API. | ||
# One way to find this information is with `curl` and `jq`: | ||
# | ||
# curl \ | ||
# --data '{"id": 0, "method": "foreach", "params": ["dhcp", "dnsmasq"]}' \ | ||
# http://192.168.1.1/cgi-bin/luci/rpc/uci?auth=$AUTH_TOKEN \ | ||
# | jq '.result | map({terraformId: .[".name"]})' | ||
# | ||
# This command will output something like: | ||
# | ||
# [ | ||
# { | ||
# "terraformId": "cfg123456", | ||
# } | ||
# ] | ||
# | ||
# We'd then use the information to import the appropriate resource: | ||
|
||
terraform import openwrt_dhcp_dnsmasq.this cfg123456 |
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,8 @@ | ||
resource "openwrt_dhcp_dnsmasq" "this" { | ||
domain = "testing" | ||
expandhosts = true | ||
id = "testing" | ||
local = "/testing/" | ||
rebind_localhost = true | ||
rebind_protection = true | ||
} |
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,40 @@ | ||
//go:build acceptance.test | ||
|
||
package dnsmasq_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
"testing" | ||
|
||
"github.com/joneshf/terraform-provider-openwrt/internal/acceptancetest" | ||
"github.com/ory/dockertest/v3" | ||
) | ||
|
||
var ( | ||
dockerPool *dockertest.Pool | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
var ( | ||
code int | ||
err error | ||
tearDown func() | ||
) | ||
ctx := context.Background() | ||
tearDown, dockerPool, err = acceptancetest.Setup(ctx) | ||
defer func() { | ||
tearDown() | ||
os.Exit(code) | ||
}() | ||
if err != nil { | ||
fmt.Printf("Problem setting up tests: %s", err) | ||
code = 1 | ||
return | ||
} | ||
|
||
log.Printf("Running tests") | ||
code = m.Run() | ||
} |
Oops, something went wrong.