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

  vars:
    debianPackages:
      - curl
      - python3-pip
      - virtualenv
      - jq

    el8Packages:
      - curl
      - python3-pip
      - python3-setuptools
      - virtualenv
      - jq

  tasks:
    - name: Install packages on debian
      package:
        name: "{{ debianPackages }}"
        state: present
      when: ansible_facts['os_family'] == "Debian"

    - name: Install packages on el8
      package:
        name: "{{ el8Packages }}"
        state: present
      when: ansible_facts['os_family'] == "RedHat"

    - name: Install xmltodict python package
      pip:
        name: xmltodict
      when: ansible_facts['os_family'] == "RedHat"

    - name: Install xmltodict python package
      shell: | 
        set -e -o pipefail
        pip install xmltodict --break-system-packages
      args:
        executable: /usr/bin/bash
      when: ansible_facts['os_family'] == "Debian"
