0

I have a VMware vCenter with several VMs. I want to use ansible to configure the network interfaces of the guest based on the network to which the VMware network interface is connected. Since the network interface names in the guest may not be named in a stable way, I want to match it based on the mac-address, which is known inside and outside the VM.

For that I want to gather information from VMware vCenter for each VM, which leads to the first question: Since the needed information is tightly coupled to the VM, should I write a *_facts (and no *_info) module for that?

Since this module code directly contacts the vCenter API, there is no need to execute the code on the target host, which leads to the 2nd question: Is there a way to always execute a module locally? (Without using delegate_to in the playbook)

And the last question: Is it possible to execute *_facts modules automatically, without explicitly referencing them in a playbook?

Zeitounator
  • 38,476
  • 7
  • 53
  • 66
jay
  • 51
  • 7
  • [Are you really sure you need to write a custom module?](https://docs.ansible.com/ansible/latest/collections/community/vmware/index.html) – Zeitounator Mar 15 '22 at 17:05
  • 1
    The module community.vmware.vmware_guest_info probably has the information I require, but I'd like to write that module at least for training purpose. In any case, I need to write other modules later and the placed questions are also relevant for these. – jay Mar 16 '22 at 07:42
  • 1
    For learning purpose, you can start by reading the code of the existing module: https://github.com/ansible-collections/community.vmware/blob/main/plugins/modules/vmware_guest_info.py – Zeitounator Mar 16 '22 at 08:52

0 Answers0