I'm neither a lawyer nor an Ansible maintainer, but Ansible is licensed under GPLv3, so if you're creating a derivative work, you'll have to release the source under the same license. I don't think there's a firm legal definition of what constitutes a "derivative work", but if you're importing Ansible's Python code and using it from another Python program, then you'll have to release it under the GPL.
If you're writing something that just _calls_ Ansible, e.g. to run a playbook, you might not have to open-source it.
pacem in terris / мир / शान्ति / سَلاَم / 平和
Kevin R. Bullock