terraform-coop / terraform-provider-foreman

Terraform provider for Foreman

Home Page:https://registry.terraform.io/providers/terraform-coop/foreman

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error updating host profile with foreman_host resource

mithun0119 opened this issue · comments

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
}

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

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

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.

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.

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

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?

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.

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