Provision VM via Tower but see it as a VM on self portal


#1

Hello,

I’m trying to find the answer since days but I feel I have no luck.
I provision a VM on RHEV via Ansible Tower that is initiated from manageIQ, that part of the process works like a charm.

Now, I’d like that the customer sees his “tower” service as a VM with all the feature like the power option, console, snapshot etc etc…
How can I achieve that?

Thanks for your help

Philippe


#2

Hi

The only way is to attach provisioned VM to service after EMS refresh by automation method. VM object have “add_to_service” method for this. You need to somehow identify this virtual machine to map to the service. Maybe name it the same as a service.

Example code for attaching vms to services:

https://pemcg.gitbooks.io/introduction-to-cloudforms-automation/content/chapter17/service_hierarchies.html


#3

Hi,

If I’m reading you correctly I should duplicate /System/Event/EmsEvent/RHEVM/USER_ADD_VM to my domain and in one of the instance field (I have no clue which point), I should point to a custom method that will link that VM to as Service?

Thanks a lot

Philippe


#4

If a new VM is created in RHV (even if created outside of ManageIQ), MIQ will discover it and it will appear in the MIQ inventory list of VMs. This normally happens within seconds of the VM being created. What you won’t get is any kind of VM ‘ownership’ by MIQ group or user; for this to happen you need to initiate the VM provisioning workflow from ManageIQ itself.

Are you initiating the VM provision from Tower itself, or from ManageIQ?

I think the best way to do this would be to create a service catalog item in ManageIQ to launch your Tower provisioning job, and then have a second workflow step to associate the new VM with the newly created ManageIQ service. This may well be easier using embedded Ansible as the playbook would automatically see {{ manageiq.service }} and {{ manageiq.api_token }} to make the association of the new VM with the new service.

There’s a neat video example here: https://cloudformsblog.redhat.com/2018/02/13/automating-instance-provisioning-with-cloudforms-and-ansible-tower-video/


#5

Yes I’m provisioning the VM from Tower and the Tower template is initiated from ManageIQ.

I follow your id, I should ansible to link the VM to my service using the two variables but I don’t know how… I looked at the link you provided but I’m not sure how this can help me.

Thanks


#6

That was the solution ! Thanks !