---

- when: >
    (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('11', '<')) or
    (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version is version('20', '<'))
  block:
    - name: Install dependencies
      apt:
        name:
          - dmidecode
          - hwdata
          - ucf
          - hdparm
          - perl
          - libuniversal-require-perl
          - libwww-perl
          - libparse-edid-perl
          - libproc-daemon-perl
          - libproc-pid-file-perl
          - libfile-which-perl
          - libxml-treepp-perl
          - libyaml-perl
          - libnet-cups-perl
          - libnet-ip-perl
          - libdigest-sha-perl
          - libsocket-getaddrinfo-perl
          - libtext-template-perl
    
    - name: Install fusioninventory
      apt: deb=http://ftp.fr.debian.org/debian/pool/main/f/fusioninventory-agent/fusioninventory-agent_{{ fusinv_deb_version }}_all.deb
      environment:
        - http_proxy: "{{ system_proxy | default('') }}"

  tags: inventory

- when: >
    (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('11', '>=')) or
    (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version is version('20', '>='))
  block:
    - name: Install FusionInventory Agent
      apt:
        name:
          - fusioninventory-agent
  tags: inventory

