Description of problem:
Post migration playbook cannot find hostname/IP address and runs against localhost. Then I checked the VM in RHV and found out that the VM did not show IP address associated with it in the UI.
Installed rhevm guest agent as outlined in this https://access.redhat.com/solutions/261763 and VM did show the IP address in UI. And if I would run the playbook now, it can get the correct IP address from VM and execute play successfully.
Version-Release number of selected component (if applicable):
5.9.4.4
How reproducible:
100%
Steps to Reproduce:
1.Create a VM without rhvm-guest-agent installed in VMware
2.Migrate it and have pre and post migration playbook services attached to migration
Actual results:
Pre-migration playbook runs correctly, while post-migration cannot, as it can't find IP address and falls back to run against localhost.
Expected results:
Post migration playbook should run successfully against migrated VM and not run against localhost.
Additional info:
I have tested running migration with rhel7-server vm with and without guest tools and found out, if I had the guest tools installed, the IP address of the VM will be available for playbook to execute.
This is the expected behavior from a playbook point of view.
The IP address is provided to RHV by the guest agent. In CloudForms, the IP address is coming from the inventory, which is limited to what information RHV provides. So, if the guest agent is not installed, RHV doesn't have the IP, hence CloudForms doesn't have it either.
About the fact that it runs against localhost, it is also on purpose because we consider that we can run a playbook even if the VM is down. It's then the responsibility of the playbook writer to ensure it can run in a limited context.
As you pointed out, the question here is "how do we ensure that the guest agent is installed during the migration process ?"