---
- hosts: pfservers
  name: configure Packetfence VM
  become: True

  tasks:
    - name: Install qemu-system-x86 on debian
      apt:
        name: qemu-system-x86
        state: present
      when: ansible_facts['os_family'] == "Debian"

    # cause a failure on RHEL
    - name: Disable Netfilter on bridge on Debian only
      ansible.posix.sysctl:
        name: "{{ item }}"
        state: 'present'
        value: '0'
        reload: yes
      loop:
        - net.bridge.bridge-nf-call-ip6tables
        - net.bridge.bridge-nf-call-iptables
        - net.bridge.bridge-nf-call-arptables
      when: ansible_facts['os_family'] == "Debian"

    - name: Install qemu-kvm on el8
      yum:
        name: qemu-kvm
        state: present
        enablerepo: "epel"
      when: ansible_facts['os_family'] == "RedHat"

    - name: For RHEL8Create a symbolic link for qemu-system-x86_64
      ansible.builtin.file:
        src: /usr/libexec/qemu-kvm
        dest: /usr/bin/qemu-system-x86_64
        state: link
      when: ansible_facts['os_family'] == "RedHat"
