Closed rishabhkalra closed 2 years ago
Thank you for the issue @rishabhkalra! Very strange indeed. What Pi-Hole version are you running? Seems to be working okay against the nightly build.
# docker run --rm -p 8080:80 -e WEBPASSWORD=password --pull always pihole/pihole:nightly
resource "pihole_dns_record" "record" {
domain = "record.com"
ip = "127.0.0.1"
}
provider "pihole" {
url = "http://localhost:8080"
password = "password"
}
terraform {
required_providers {
pihole = {
source = "ryanwholey/pihole"
version = "0.0.9"
}
}
}
I run traefik on my cluster at home and pass provider credentials using env vars similar to these
export PIHOLE_URL=https://pihole.my-domain.com
export PIHOLE_PASSWORD=my-web-login-password
The provider URL is intended to be the protocol://domain.tld
, you're saying that you got the provider to work by appending /index.php?login
to your provider.url?
I've also got API token auth support (https://github.com/ryanwholey/terraform-provider-pihole/issues/27) on the horizon which should be easier to manage, but the API still seems to be changing a bit so we will see.
@ryanwholey Thanks for the prompt reply on this!
What Pi-Hole version are you running?
I'm on Pi-hole v5.8.1, FTL v5.13, and web interface v5.10.1
The provider URL is intended to be the protocol://domain.tld, you're saying that you got the provider to work by appending /index.php?login to your provider.url?
That is correct, if I leave it as https://pihole.internal.mydomain.dev
I see that error I put in the bottom of the issue description. However if I use https://pihole.internal.mydomain.dev/index.php?login
I don't see that error and it attempts to create the dns record (which still fails with the '>' error)
I can try updating pihole and see if that fixes it 🤔
@rishabhkalra
Okay I think I've found a way to reproduce what you're seeing, I believe the domain you're supplying actually resolves to <your-pihole-url>/admin
.
provider "pihole" {
url = "http://localhost:8080/admin"
}
│ Error: login failed: session ID not found in response
│
│ with provider["registry.terraform.io/ryanwholey/pihole"],
│ on main.tf line 6, in provider "pihole":
│ 6: provider "pihole" {
│
provider "pihole" {
url = "http://localhost:8080/admin/index.php?login"
}
│ Error: invalid character '<' looking for beginning of value
│
│ with pihole_dns_record.record,
│ on main.tf line 1, in resource "pihole_dns_record" "record":
│ 1: resource "pihole_dns_record" "record" {
│
╵
provider "pihole" {
url = "http://localhost:8080"
}
No changes. Your infrastructure matches the configuration.
Can you check your ingress rules and see if this is the case?
Thanks for looking into this! Turns out that did seem to be the issue. I was adding a prefix of /admin
in my ingress rule 😅 I now have an entirely different issue to deal with something else being broken in my infrastructure haha. But it seemed that fixed the issue and I could see my dns record get created 😄
Thanks so much for the help @ryanwholey !
happy to help, thank you for testing out the provider!
I was just trying to automate DNS entry creation as I create VMs.
Error
Details
I've already made sure I'm using the admin password used for logging into pihole (as was stated in #22). Not entirely sure what's going on because I think I've set everything up correctly. I am using a traefik reverse proxy in front of pihole for HTTPS so the url I pass into that variable ends with
/index.php?login
. That was the only way I could get it to not error out trying to connect. I see the following error if I try to omit that bit.