No description
  • Go 98.7%
  • Makefile 1.3%
Find a file
Andrew Morris 59b252efe8
feat: Update go-pihole to v1.2.0 for Pi-hole v6 support (#93)
Updates the go-pihole dependency from v1.1.0 to v1.2.0 which includes
support for Pi-hole v6 API. This resolves authentication issues with
newer Pi-hole installations.

The v1.2.0 release includes the necessary changes to work with Pi-hole
v6's updated API structure while maintaining backward compatibility.

Fixes authentication error: 'login failed: session ID not found in response'

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-23 12:16:02 -06:00
.github build(deps): bump hashicorp/ghaction-terraform-provider-release (#78) 2025-04-01 23:20:56 -06:00
docs Updated docs for the beta version (#94) 2025-09-23 12:11:41 -06:00
examples Updated docs for the beta version (#94) 2025-09-23 12:11:41 -06:00
internal feat(v6 refactor)!: Refactor provider for new pihole v6 API (#87) 2025-03-19 00:07:25 -06:00
templates feat: Lazy login for dynamic provider scenario (#62) 2023-11-21 23:05:01 -07:00
.gitignore feat(v6 refactor)!: Refactor provider for new pihole v6 API (#87) 2025-03-19 00:07:25 -06:00
.goreleaser.yml dev: Copy goreleaser from scaffold 2025-04-03 22:21:47 -06:00
CHANGELOG.md dev: update changelog (#34) 2022-02-19 22:50:10 -07:00
docker-compose.yml feat(v6 refactor)!: Refactor provider for new pihole v6 API (#87) 2025-03-19 00:07:25 -06:00
GNUmakefile docs: Run generate docs + update docs tooling (#83) 2024-09-13 22:35:55 -06:00
go.mod feat: Update go-pihole to v1.2.0 for Pi-hole v6 support (#93) 2025-09-23 12:16:02 -06:00
go.sum feat: Update go-pihole to v1.2.0 for Pi-hole v6 support (#93) 2025-09-23 12:16:02 -06:00
LICENSE Initial commit 2021-10-31 18:19:16 -06:00
main.go Add initial resources, docs, workflows (#1) 2021-10-31 19:16:10 -06:00
README.md Update README.md 2025-03-24 22:12:44 -06:00
terraform-registry-manifest.json dev: Forgot to commit manifest 2025-04-03 22:56:11 -06:00

terraform-provider-pihole

test workflow status terraform registry

Pi-hole is an ad blocking application which acts as a DNS proxy that returns empty responses when DNS requests for known advertisement domains are made from your devices. It has a number of additional capabilities like optional DHCP server capabilities, specific allow/deny profiles for specific clients, and a neat UI with a ton of information regarding your internet traffic.

Pi-hole is an open source project and can be found at https://github.com/pi-hole/pi-hole.

Usage

This provider is published to the Terraform Provider registry.

terraform {
  required_providers {
    pihole = {
      source  = "ryanwholey/pihole"
      version = "x.x.x"
    }
  }
}

Configure the provider with credentials, or pass environment variables.

provider "pihole" {
  url       = "https://pihole.domain.com" # PIHOLE_URL
  password  = var.pihole_password         # PIHOLE_PASSWORD
}

See the provider documentation for more details.

Provider Development

There are a few ways to configure local providers. See the somewhat obscure Terraform plugin installation documentation for a potential recommended way.

One way to run a local provider is to build the project, move it to the Terraform plugins directory and then use a required_providers block to note the address and version.

Note

Note the /darwin_arm64/ path portion targets a Mac with an ARM64 processor, see https://github.com/ryanwholey/terraform-provider-pihole/blob/main/.goreleaser.yml#L18-L27 for possible supported combinations.

# from the project root
go build .

mkdir -p ~/.terraform.d/plugins/terraform.local/local/pihole/0.0.1/darwin_arm64/

cp terraform-provider-pihole ~/.terraform.d/plugins/terraform.local/local/pihole/0.0.1/darwin_arm64/terraform-provider-pihole_v0.0.1

In the Terraform workspace, use a required_providers block to target the locally built provider

terraform {
  required_providers {
    pihole = {
      source  = "terraform.local/local/pihole"
      version = "0.0.1"
    }
  }
}

Testing

Testing a Terraform provider comes in several forms. This chapter will attempt to explain the differences, where to find documentation, and how to contribute.

Note

For the current tests in this repository the SDKv2 is used. In issue #4 an upgrade from SDKv2 to plugin-testing can be tracked.

Unit testing

make test

Acceptance testing

The make testall command is prefixed with the TF_ACC=1. This tells go to include the tests that utilise the helper/resource.Test() functions.

For further reading, please see Hashicorp's documenation on acceptance tests.

To setup a proper environment combining an instance of Pihole in a docker container with tests, some environment variables need to be set for the tests to make their requests to the correct location.

Run the following commands to test against a local Pi-hole server via docker

# Set the local Terraform provider environment variables
export PIHOLE_URL=http://localhost:8080
export PIHOLE_PASSWORD=test

# Start the pi-hole server
make docker-run

# Run Terraform tests against the server
make testall

To test against a specific Pi-hole image tag, specify the tag via the TAG env var

TAG=nightly make docker-run

For further reading about Terraform acceptance tests, see Hashicorp's documenation on acceptance tests.

Docs

Documentation is auto-generated via tfplugindocs from description fields within the provider package, as well as examples and templates from the examples/ and templates/ folders respectively.

To generate the docs run

make docs