Friday, April 1, 2022

vRealize Automation fails to remove machines from Ansible Inventory

 Recently I've been working with one of my customers to create a fully automated offering on their Cloud Management Portal for their end-users to consume.
vRealize Automation (vRA) is their cloud management choice, not only because it's mult-cloud, governance and ease of use capabilities, but also because it's powerfull extensibility options providing all the integrations and automation to deliver fully compliant and customized workloads ready for production.

In charge of their configuration management they decided to use Ansible Playbooks, not a problem for vRA and it's native integration. So when a VM gets created  some playbooks will run to hardening the VM and make some configuration, so far so good.

But when deleting the VM we got an error; not being able to delete it beucase it was not possible to remove the VM from Ansible inventory first.
Checking vRA deployment logs we can see: Unable to parse inventory to obtain existing groups JSON for host : "hostname" in inventory "invetory_path" . ​​Ensure inventory is valid and host exists.. Refer to logs located at: var/tmp/vmware/provider/user_defined_script/<Deployment ID> on Ansible Control Machine for more details.


Checking the Ansible Inventory we confirmed the VM is still in there and vRA Deployment could not proceed to delete the VM.

First we made sure all the requirements were there. They were !!

But what stood up was the message that it could not parse the JSON, is there anything wrong with the JSON ?

So we went back to Ansible and ran some callbacks to make sure it's returning the right information
we ran: ANSIBLE_STDOUT_CALLBACK=json ANSIBLE_LOAD_CALLBACK_PLUGINS=true ansible "VM"-m debug -a var=group_names -i "inventory_path_file"

To our surprise, there was an extra line outside of the JSON with the timer information.




It might be something on the Ansible's configuration !!!
After some seriously analisys and tests we find out a configuration section about callback plugins and one of them had the timer option.



So we removed the timer option from callback_whitelist option



Running the callback command again we confirmed  the JSON comes clear and vRA deletion just worked as expected.


Curious enough this requirement is not on vRA Ansible requirements documentation, To be honest I'm not sure if it was something specific with this customer implementation or Ansible version but I'll mention this internally, possibly for a bugfix. either way now you know how to fix it.

A shout-out to my buddy Sean Leahy working with us all the way on this jorney.




No comments:

Post a Comment

Who am I

My photo
I’m an IT specialist with over 15 years of experience, working from IT infrastructure to management products, troubleshooting and project management skills from medium to large environments. Nowadays I'm working for VMware as a Consulting Architect, helping customers to embrace the Cloud Era and make them successfully on their journey. Despite the fact I'm a VMware employee these postings reflect my own opinion and do not represents VMware's position, strategies or opinions. Reach me at @dumeirell

Most Viewed Posts

Blog Archive