Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create puppetdb_node resource #7

Open
Wiston999 opened this issue Jun 4, 2020 · 1 comment
Open

Unable to create puppetdb_node resource #7

Wiston999 opened this issue Jun 4, 2020 · 1 comment

Comments

@Wiston999
Copy link

Hi,
Thanks for puppetca and this provider.
I'm having some issues trying to use the provider that I'm not able to debug.
The code being used is

locals {
  puppet_enabled = lookup(var.base_tags, "puppet", "false") == "true" ? 1 : 0
}

resource puppetdb_node "puppetdb-metadata" {
  count    = var.srv_count * local.puppet_enabled
  certname = replace(azurerm_private_dns_a_record.a_record[count.index].fqdn, "/\\.$/", "")
}

resource puppetca_certificate "puppetca-metadata" {
  count = var.srv_count * local.puppet_enabled
  name = replace(azurerm_private_dns_a_record.a_record[count.index].fqdn, "/\\.$/", "")
}

Providers configuration is:

provider "puppetca" {
  url  = var.puppetca_host
  cert = var.puppet_cert
  key  = var.puppet_key
  ca   = var.puppet_ca_cert
}

provider "puppetdb" {
  url  = var.puppetdb_host
  cert = var.puppet_cert
  key  = var.puppet_key
  ca   = var.puppet_ca_cert
}

In fact, puppetca_certificate worked without issues at the first time.
After 51 tries, the error returned is

Error waiting for node (dev-01.str.global.example.com) to be found: couldn't find resource

And, if I reproduce using curl I get:

$ curl -k -i  --cacert /etc/puppetlabs/puppet/ssl/ca/ca_crt.pem --key /etc/puppetlabs/puppet/ssl/private_keys/$(hostname -f).pem --cert /etc/puppetlabs/puppet/ssl/certs/$(hostname -f).pem https://puppet.example.com:8145/pdb/query/v4/nodes/dev-01.str.global.example.com -H 'Content-Type: application/json' -H 'Accept: application/json'
HTTP/1.1 200 OK
Date: Thu, 04 Jun 2020 11:49:17 GMT
Content-Type: application/json;charset=utf-8
Vary: Accept-Encoding, User-Agent
Content-Length: 676

{
  "deactivated" : null,
  "latest_report_hash" : "6ba6505370755521a9eed033c5da84c5de444910",
  "facts_environment" : "production",
  "cached_catalog_status" : "not_used",
  "report_environment" : "production",
  "latest_report_corrective_change" : null,
  "catalog_environment" : "production",
  "facts_timestamp" : "2020-06-04T11:45:43.413Z",
  "latest_report_noop" : false,
  "expired" : null,
  "latest_report_noop_pending" : false,
  "report_timestamp" : "2020-06-04T11:47:39.272Z",
  "certname" : "dev-01.str.global.example.com",
  "catalog_timestamp" : "2020-06-04T11:46:45.306Z",
  "latest_report_job_id" : null,
  "latest_report_status" : "changed"
}

Am I doing anything wrong or might be a provider bug?

@Wiston999
Copy link
Author

Found the issue.
The domain I was using for PuppetDB wasn't included in HTTPS certificate, so the client was failing silently.
I changed the puppetdb_host to a domain that was part of the server certificate and it worked like a charm.

So, I was doing something wrong, but I guess this could be checked in the code or at least documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant