terraform-coop / terraform-provider-foreman

Terraform provider for Foreman
https://registry.terraform.io/providers/terraform-coop/foreman
Mozilla Public License 2.0
33 stars 31 forks source link

Resource "foreman_katello_product" One of parameters [ organization_id ] required but not specified #151

Closed lukry59 closed 4 months ago

lukry59 commented 5 months ago

Hello,

Resource foreman_katello_product seems not working on Katello 4.11, asking to specify organization_id. In documentation organization_id parameter not available on this resource

https://registry.terraform.io/providers/terraform-coop/foreman/latest/docs/resources/foreman_katello_product

main.tf :

terraform {
  required_providers {
    foreman = {
      source = "terraform-coop/foreman"
      version = "0.6.2"
    }
  }
}

provider "foreman" {
  provider_loglevel = "debug"
  provider_logfile = "terraform-provider-foreman.log"

  client_username = <HIDDEN>
  client_password = <HIDDEN>
  client_tls_insecure = "true"

  server_hostname = <HIDDEN>
  server_protocol = "https"
  organization_id = "1"
  location_id = "1"
}

resource "foreman_katello_product" "example" {
  description = "Test terraform"
  name = "Debian 12"
}

output "out" {
    value = resource.foreman_katello_product.example
}

Terraform apply output :

➜  katello-terraform terraform apply

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:

  # foreman_katello_product.example will be created
  + resource "foreman_katello_product" "example" {
      + __meta__    = (known after apply)
      + description = "Test terraform"
      + id          = (known after apply)
      + name        = "Debian 12"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + out = {
      + __meta__     = (known after apply)
      + description  = "Test terraform"
      + gpg_key_id   = null
      + id           = (known after apply)
      + label        = null
      + name         = "Debian 12"
      + sync_plan_id = null
    }

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

foreman_katello_product.example: Creating...
╷
│ Error: HTTP Error:{
│   endpoint:   [https://<HIDDEN>/katello/api/products]
│   statusCode: [404]
│   respBody:   [{"displayMessage":"One of parameters [ organization_id ] required but not specified.","errors":["One of parameters [ organization_id ] required but not specified."]}]
│ }
│ 
│   with foreman_katello_product.example,
│   on main.tf line 25, in resource "foreman_katello_product" "example":
│   25: resource "foreman_katello_product" "example" {
│ 
╵

terraform-provider-foreman.log :

2024/01/11 17:59:20 [TRACE] config.go#Client
2024/01/11 17:59:20 [TRACE] foreman/api/client.go#NewClient
2024/01/11 17:59:20 [DEBUG] Server: [{URL:{Scheme:https Opaque: User: Host:<HIDDEN> Path: RawPath: OmitHost:false ForceQuery:false RawQuery: Fragment: RawFragment:}}], ClientConfig: [{TLSInsecureEnabled:true NegotiateAuthEnabled:false LocationID:1 OrganizationID:1}]
2024/01/11 17:59:20 [DEBUG] Rest Client configured
2024/01/11 17:59:24 [TRACE] config.go#Client
2024/01/11 17:59:24 [TRACE] foreman/api/client.go#NewClient
2024/01/11 17:59:24 [DEBUG] Server: [{URL:{Scheme:https Opaque: User: Host:<HIDDEN> Path: RawPath: OmitHost:false ForceQuery:false RawQuery: Fragment: RawFragment:}}], ClientConfig: [{TLSInsecureEnabled:true NegotiateAuthEnabled:false LocationID:1 OrganizationID:1}]
2024/01/11 17:59:24 [DEBUG] Rest Client configured
2024/01/11 17:59:24 [TRACE] resource_foreman_katello_product.go#Create
2024/01/11 17:59:24 [TRACE] resource_foreman_katello_product.go#buildForemanKatelloProduct
2024/01/11 17:59:24 [DEBUG] ForemanKatelloProduct: [&{ForemanObject:{Id:0 Name:Debian 12 CreatedAt: UpdatedAt:} Description:Test terraform GpgKeyId:0 SyncPlanId:0 Label:}]
2024/01/11 17:59:24 [TRACE] foreman/api/product.go#Create
2024/01/11 17:59:24 [DEBUG] KatelloProductJSONBytes: [{"created_at":"","description":"Test terraform","gpg_key_id":0,"id":0,"label":"","name":"Debian 12","sync_plan_id":0,"updated_at":""}]
2024/01/11 17:59:24 [TRACE] foreman/api/client.go#NewRequestWithContext
2024/01/11 17:59:24 [DEBUG] method: [POST], endpoint: [katello/products]
2024/01/11 17:59:24 [DEBUG] reqURL: [https://<HIDDEN>/katello/api/products]
2024/01/11 17:59:24 [TRACE] foreman/api/client.go#SendAndParse
2024/01/11 17:59:24 [TRACE] foreman/api/client.go#Send
2024/01/11 17:59:24 [DEBUG] server response:{
  endpoint:   [https://<HIDDEN>/katello/api/products]
  method:     [POST]
  statusCode: [404]
  respBody:   [{"displayMessage":"One of parameters [ organization_id ] required but not specified.","errors":["One of parameters [ organization_id ] required but not specified."]}]
}
lukry59 commented 5 months ago

Didn't saw, this issue is a duplicate of #54

bitkeks commented 5 months ago

...and should be fixed with commit bc544ceddb86f143bf72d14929419623d2811812 :+1: