Relative Content

Tag Archive for ansibleansible-collections

Custom Ansible Module Testing Examples

I created a collection with some custom modules to do some VMware Automation (specifically VCF as I already know there is a collection for both nsx and vcenter). But I wanted to ask is there any good resources out there that go through how to test those modules (I want to test mocking the apis to make sure the logic in my custom module works). I already have both input and response payloads to mimic and my modules work somewhat I just want to add some unit testing as provision takes hours and rebuilds take time as well so I was trying to figure out methods to still test my methods to some degree (make sure I’m not doing spelling errors or silly human mistakes) without doing a full build. Also, it’s ok if I’m not thinking about this the right way just trying to ask some ppl who maybe a bit more adv in ansible. I know how to do unit test in python but as you know running python in ansible is a bit different than pure python. So I doing this as a learning experience to learn ansible (I also know there is a terraform provider for this as well). I’m really just trying to speed up my testing process