terraform-coop / terraform-provider-foreman

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

Fix updating params #29

Closed Fodoj closed 3 years ago

Fodoj commented 3 years ago

Due to wrong API call, it never fetched the correct list of params, thus making idempotency none-existent

lhw commented 3 years ago

I don't think this is correct. I checked the line for changes and current and old api documentation. The parameter has always been host_parameters_attributes as far as I can tell. And I am using it in our production environment and have not yet had any issues with idempotency.

Fodoj commented 3 years ago

@lhw on update/create its host_parameter_attributes; on show its parameters ( see https://theforeman.org/api/2.0/apidoc/v2/hosts/show.html). Problem is that in current version it will just always send same parameters list and save them to statefile. But it will never detect changes to existing params (try changing some param manually in Foreman UI, then run terraform plan), or newly manually added params (try adding new param outside of Terraform, and run plan - it wont see there is a new param). Current version only compares with what is inside the statefile, which is always what you have defined in the template. But params from API are never retrieved for comparison.

Fodoj commented 3 years ago

Also see https://github.com/HanseMerkur/terraform-provider-foreman/pull/29/files#diff-1c2c1e4478457d1014e760b4b65a9a558e986d83eeeb398b77148dd7721598dbR173. It's once again one of those things where Foreman missed out on opportunity to provide consistent API.

lhw commented 3 years ago

Alright. That makes sense. We don't have anyone fiddling with the foreman ui. Just terraform these days.