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

Error updating host profile with foreman_host resource #75

Closed mithun0119 closed 2 years ago

mithun0119 commented 2 years ago

While trying to update the host profile with foreman_host resource, the below error stops from progressing. Location_id is not a valid argument to pass either, while it has to be. The tf template is just a basic one, trying to update the hostgroup_id.

I am using version 0.3.1 on MAC with terraform version 0.15.5 as the newer versions are incompatible.

foreman_host.xxxxxtst101: Creating... ╷ │ Error: HTTP Error:{ │ endpoint: [https://foreman/api/hosts] │ statusCode: [404] │ respBody: [{"message":"Location with id 0 not found"}] │ } │ │ with foreman_host.xxxxxtst101, │ on main.tf line 29, in resource "foreman_host" "xxxxxtst101": │ 29: resource "foreman_host" "xxxxxtst101" { │

TF template excerpt:

data "foreman_hostgroup" "test" { title = "debian/server/test" }

resource "foreman_host" "xxxxxtst101" { name = "xxxxxtst101" hostgroup_id = data.foreman_hostgroup.test.id }

mithun0119 commented 2 years ago

I tested the same on Debian OS with the latest version 0.4.5 and still get the same error.

MrFreezeex commented 2 years ago

What do you have in the foreman provider config? I think location_id is added with something in the config...

MrFreezeex commented 2 years ago

What do you have in the foreman provider config? I think location_id is added with something in the config...

Ah well actually I think you have an old foreman version so you should set location_id to -1 in the config, see https://github.com/HanseMerkur/terraform-provider-foreman/blob/master/foreman/provider.go#L162.

mithun0119 commented 2 years ago

Can this be used to update an existing profile or only to add a new one? Anyone has experience updating an existing foreman host profile.

MrFreezeex commented 2 years ago

Not sure what you mean by profile, but that's in the provider config so there is nothing to change in your host resource.

mithun0119 commented 2 years ago

What I mean is if a host profile already in forman needs a change of hostgroup and location and many other fields, is that possible with this module?

MrFreezeex commented 2 years ago

What I mean is if a host profile already in forman needs a change of hostgroup and location and many other fields, is that possible with this module?

Well you can import it in terraform and then you should be able to change most of the fields yes.

lhw commented 2 years ago

Is the discussion still on-going or has the issue solved itself?