---

- name: Check if qemu agent channel is available
  stat: path=/dev/virtio-ports/org.qemu.guest_agent.0
  register: qemu_ga_dev

- when:
    - qemu_ga_dev.stat.exists | default(False)
    - ansible_virtualization_type == 'kvm'
  block:
    - name: Install qemu guest agent
      package:
        name:
          - qemu-guest-agent

    - name: Start and enable qemu guest agent
      service: name=qemu-guest-agent state=started enabled=True

- when: ansible_virtualization_type == 'VMware'
  block:
    - name: Install open-vm-tools
      package:
        name:
          - open-vm-tools

    - name: Start and enable vmtoolsd
      service: name=vmtoolsd state=started enabled=True
