- name: install mandatory packages (FreeBSD)
  pkgng:
    name: "{{ mandatory_packages[ansible_distribution] }}"
    state: present
  when: ansible_distribution == "FreeBSD"
  environment: "{{ proxy_env }}"

- name: install utility packages (FreeBSD)
  pkgng:
    name: "{{ utility_packages[ansible_distribution] }}"
    state: present
  when: ansible_distribution == "FreeBSD"
  environment: "{{ proxy_env }}"

- name: install mandatory packages (Debian)
  apt:
    name: "{{ mandatory_packages[ansible_distribution] }}"
    state: present
  when: ansible_distribution == "Debian"
  environment: "{{ proxy_env }}"

- name: install utility packages (Debian)
  apt:
    name: "{{ utility_packages[ansible_distribution] }}"
    state: present
  when: ansible_distribution == "Debian"
  environment: "{{ proxy_env }}"

- name: install mandatory packages
  package:
    name: "{{ mandatory_packages[ansible_distribution] }}"
    state: present
  environment: "{{ proxy_env }}"

- name: install utility packages
  package:
    name: "{{ utility_packages[ansible_distribution] }}"
    state: present
  environment: "{{ proxy_env }}"

Use package module to remove duplicate package installs
Use package module to remove duplicate package installs
