Closed MaximeMnt closed 2 weeks ago
I knew this day would come. The API does indeed change which can be tough. I'll try to take a look at this over the next few weeks, might need to put out a new major version if the provider changes break existing functionality.
I have the same problem with an earlier version than the one from the issue author. In fact, the above error occurs when connecting to PiHole via API token.
Alternatively, I tried the connection with password and get the following error:
Error: login failed: session ID not found in response
I am using Pi-hole v5.17.1 FTL v5.23 Web Interface v5.20.1
I would be very happy about a fix.
@MaximeMnt apologies for the delay, I cannot reproduce your issue. I'm trying to think about what could be different.
I tried with both password and api-token
PIHOLE_URL=http://localhost:8080
PIHOLE_PASSWORD=test
or
PIHOLE_API_TOKEN=7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c
My versions:
Pi-Hole: Docker Tag 2024.05.0 Pi-hole v5.18.2 FTL v5.25.2 Web Interface v5.21
provider: 0.2.0
Terraform: v1.5.7
# main.tf
resource "pihole_dns_record" "dns_record" {
for_each = {for record in var.dns_records: record.domain => record}
domain = each.value.domain
ip = each.value.ip
}
variable "dns_records" {
default = {
aa = {
domain = "aa.com",
ip = "10.0.0.1"
},
}
}
terraform {
required_providers {
pihole = {
source = "ryanwholey/pihole"
version = "0.2.0"
}
}
}
$ terraform apply -auto-approve
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
+ create
Terraform will perform the following actions:
# pihole_dns_record.record["aa.com"] will be created
+ resource "pihole_dns_record" "record" {
+ domain = "aa.com"
+ id = (known after apply)
+ ip = "10.0.0.1"
}
Plan: 1 to add, 0 to change, 0 to destroy.
pihole_dns_record.record["aa.com"]: Creating...
pihole_dns_record.record["aa.com"]: Creation complete after 0s [id=aa.com]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Thank you for your reply @ryanwholey. I have tested it one more time today and looks like I forgot to add the port to my pihole_hostname variable. Everything seems to work when I add the port. Apologies! Thanks for you help!
@MaximeMnt Ah nice, I'm happy to hear the issue has resolved for you!
@Sp0rTB4cK I ran the same test with the versions you provided and was not able to reproduce.
Docker Tag 2023.05.2 · Update available! Pi-hole v5.17.1 FTL v5.23 Web Interface v5.20.1
Since the original issue has resolved I'm going to close, but please feel free to open a new issue if you are still running into problems. Thanks!
Looks like the creation of DNS records are broken. I'm getting the following error message:
2024-06-03T23:48:54.149+0200 [ERROR] vertex "pihole_dns_record.dns_record[\"aa.com\"]" error: failed to parse customDNS response body: invalid character '<' looking for beginning of value
This is my code:
And variables:
Looks like the response from pihole has changed over the years. Is it possible to get an update?
EDIT: My pihole version: Pi-hole v5.18.2 FTL v5.25.2 Web Interface v5.21