PUT Rebuild api is not returning the desired response in Foreman v2.1

**Problem When I’m hitting the foreman v2.1 rebuild api ( PUT /api/hosts/:id/rebuild_config) through php script I’m getting 422 http code not 200 http code. This rebuild foreman functionality was working v1.20 but not v2.1. Getting below response from the api
{“message”:“Configuration rebuild failed for: SSH_Nic and SSH_Host.”}

Please guide me how to fix this issue.

I think this comes from REX, but I forgot the exact @remote_execution any idea?

Yes, there was an issue back then when known hosts keys cleanup was introduced which manifested itself this way, but it should be fixed by now.

@rahul Anything related to this in production.log?

@aruzicka My Production.log file
2020-12-02T19:29:16 [I|app|] Started PUT “/api/hosts/879/rebuild_config” for 127.0.0.1 at 2020-12-02 19:29:16 -0800
2020-12-02T19:29:16 [I|app|] Processing by Api::V2::HostsController#rebuild_config as JSON
2020-12-02T19:29:16 [I|app|] Parameters: {“host”=>"{}", “apiv”=>“v2”, “id”=>“879”}

2020-12-02T19:29:16 [D|app|] Authenticated user dummy against INTERNAL authentication source
2020-12-02T19:29:16 [D|app|] Post-login processing for dummy
2020-12-02T19:29:16 [I|app|] Authorized user dummy(dummy User)
2020-12-02T19:29:16 [D|app|] Post-login processing for dummy

2020-12-02T19:29:16 [D|tax|] Current location set to none
2020-12-02T19:29:16 [D|tax|] Current organization set to none
2020-12-02T19:29:16 [D|tax|] Current location set to none
2020-12-02T19:29:16 [D|tax|] Current organization set to none
2020-12-02T19:29:16 [I|app|] Delete DHCP reservation dummyupdare.dummy.com for dummyupdare.dummy.com-56:6f:85:55:01:f8/10.x.x.137

2020-12-02T19:29:16 [I|app|] Create DHCP reservation dummyupdare.dummy.com for dummyupdare.dummy.com-56:6f:85:55:01:f8/10.x.x.137
2020-12-02T19:29:16 [D|app|] DHCP reservation on net 10.x.x.0 with attrs: {:hostname=>“dummyupdare.dummy.com”, :mac=>“56:6f:85:55:01:f8”, :ip=>“10.x.x.137”, :network=>“10.x.x.0”, :nextServer=>“10.x.x.10”, :filename=>“pxelinux.0”, :name=>“dummyupdare.dummy.com”, :related_macs=>}
2020-12-02T19:29:16 [I|app|] DNS record type aaaa not supported for dummyupdare.dummy.com, skipping orchestration rebuild
2020-12-02T19:29:16 [I|app|] DNS record type ptr6 not supported for dummyupdare.dummy.com, skipping orchestration rebuild
2020-12-02T19:29:16 [I|app|] Delete the DNS A record for dummyupdare.dummy.com/10.x.x.137
2020-12-02T19:29:16 [I|app|] Add DNS A record for dummyupdare.dummy.com/10.x.x.137

2020-12-02T19:29:17 [I|app|] Delete the DNS PTR record for 10.x.x.137/dummyupdare.dummy.com
2020-12-02T19:29:17 [D|app|] Fetching DNS reservation for 10.x.x.137/dummyupdare.dummy.com
2020-12-02T19:29:17 [I|app|] Add DNS PTR record for 10.x.x.137/dummyupdare.dummy.com
2020-12-02T19:29:17 [I|app|] Deploying TFTP PXELinux configuration for dummyupdare.dummy.com
2020-12-02T19:29:17 [I|app|] Deploying TFTP PXEGrub2 configuration for dummyupdare.dummy.com
2020-12-02T19:29:17 [I|app|] Deploying TFTP PXEGrub configuration for dummyupdare.dummy.com
2020-12-02T19:29:17 [D|app|] Body: {“message”:“Configuration rebuild failed for: SSH_Nic and SSH_Host.”}
2020-12-02T19:29:17 [I|app|] Completed 422 Unprocessable Entity in 1298ms (Views: 0.7ms | ActiveRecord: 96.1ms | Allocations: 167860)