I need to know the name of the network adapter. Since sometimes it is eth0 and other times ens192 for vwmare and rhev machines is it possible?
You need to be more specific. What do you mean by "the" network
adapter? Which one?
For example when i deploy one virtual machine from template,
To be able to run something that tells me: the network adapter is eht0, or is ens133 etc.
I want to extract the name of the network adapter that is generated with ansible
I have tried vmware_guest but it doesn’t work
Hi,
The vmware_guest module talks to the vSphere API, which doesn’t know about Linux internals (unless exposed by vmware tools). But after deployment, I suppose you could connect to the newly created system using ansible through SSH, and use ansible facts.
If you set gather_facts: yes in your playbook (which is default), you have access to a variable called ansible_interfaces which contains a list of all the interfaces. Here an example:
$ cat interfaces.yml
Thanks for the reply
The problem I have is that I have to configure the machine with cloud init and I must know the network adapter, I cannot connect via ssh.
Another strategy is to disable predictable interface names in your image, so your interfaces be eth0 etc again