---
- name: Check cpu vendor
  set_fact:
    cpu_vendor: "{{ item }}"
  when: ansible_processor[1]|lower is search(item)
  with_items:
    - intel
    - amd
- name: Check virt extensions on cpu flags
  shell: egrep 'vmx|svm' /proc/cpuinfo
  register: cpuflags
  failed_when: false
  no_log: true
  when: cpu_vendor is defined
- name: Set qemu as virt type
  set_fact:
    virt_type: qemu
  when: cpu_vendor is not defined or cpuflags.stdout == ""
- name: Set kvm as virt type
  set_fact:
    virt_type: kvm
  when: cpu_vendor is defined and cpuflags.stdout != ""
- name: Print virtualization type
  debug:
    var: virt_type
