I use these ansible facts for differentiating between physical and virtual
guests:
"ansible_virtualization_role": "guest",
"ansible_virtualization_type": "kvm",
These work perfect along with a 'when' conditional. For example:
- template:
src: <templatefile for virtual machine on control node>
dest: <the destination on managed host>
when: ansible_virtualization_role is defined or
ansible_virtualization_role == "kvm"
If you want to explore more variables, run the following adhoc command on
both the physical and virtual hosts and notice the change is the value of
variables that facts report:
#ansible all -m setup | less
-R.Rao
On Fri, 12 Apr 2019 at 17:50, Bruno Cochofel <[email protected]>
wrote:
> Hi,
>
> I'm trying to write a role that has different template file if the server
> is virtual os physical.
> What's the best way to filter this?
>
> Thanks,
> Bruno
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/9d6a483a-90fb-4f17-a2df-45c0832971ec%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/9d6a483a-90fb-4f17-a2df-45c0832971ec%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAKbF63h1UGkrx55Kj41df4pXo05eAUCyjhU0J93%2B9NCzr%2Bbo3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.