---
- name: "add '{{ key }}' gpg key"
  apt_key: >
    state=present
    url="{{ key }}"

- name: "add '{{ repo }}' repository"
  apt_repository: >
    repo="{{ repo }}"
    state=present
    update_cache=yes

- name: "install '{{ name }}' pre-packages"
  package: >
    name="{{ item }}"
    state=present
  with_items: "{{ pre }}"

- name: "install '{{ name }}' package"
  package: >
    name="{{ name }}"
    state=present

- name: "install '{{ name }}' post-packages"
  package: >
    name="{{ item }}"
    state=present
  with_items: "{{ post }}"

---
- name: "add '{{ key }}' gpg key"
  apt_key: >
    state=present
    url="{{ key }}"
  when: key is defined

- name: "add '{{ repo }}' repository"
  apt_repository: >
    repo="{{ repo }}"
    state=present
    update_cache=yes
  when: repo is defined

- name: "install '{{ name }}' pre-packages"
  package: >
    name="{{ item }}"
    state=present
  with_items: "{{ pre }}"

- name: "install '{{ name }}' package"
  package: >
    name="{{ name }}"
    state=present

- name: "install '{{ name }}' post-packages"
  package: >
    name="{{ item }}"
    state=present
  with_items: "{{ post }}"

Fix problem with empty params
Fix problem with empty params
