I've written a small playbook to run the sudo /usr/sbin/dmidecode -t1 | grep -i vmware | grep -i product command and write the output in a result file by usign the following code as a .yml:
# Check if server is vmware
---
- name: Check if server is vmware
  hosts: all
  become: yes
  #ignore_errors: yes
  gather_facts: False
  serial:  50
  #become_flags: -i
  tasks:
    - name: Run uptime command
      #become: yes
      shell: "sudo /usr/sbin/dmidecode -t1 | grep -i vmware | grep -i product"
      register: upcmd
    - debug:
        msg: "{{ upcmd.stdout }}"
    - name: write to file
      lineinfile:
        path: /home/myuser/ansible/mine/vmware.out
        create: yes
        line: "{{ inventory_hostname }};{{ upcmd.stdout }}"  
      delegate_to: localhost
      #when: upcmd.stdout != ""
When running the playbook against a list of hosts I get different weird results so even if the  debug shows the correct output, when I check the /home/myuser/ansible/mine/vmware.out file I see only part of them being present. Even weirder is that if I run the playbook again, I will correctly populate the whole list but only if I run this twice. I have repeated this several times with some minor tweaks but not getting the expected result. Doing -v or -vv shows nothing unusual.
The output of the sudo dmidecode -t1 command:
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 2.4 present.
Handle 0x0001, DMI type 1, 27 bytes
System Information
        Manufacturer: VMware, Inc.
        Product Name: VMware Virtual Platform
        Version: None
        Serial Number: VMware-42 15 27 29 d2 1d 0b 1e-ec 62 1a 6b a1 f2 af 11
        UUID: 12165229-d21d-0b0e-ec63-1b6aa2e7nf92
        Wake-up Type: Power Switch
        SKU Number: Not Specified
        Family: Not Specified