- name: Purge python packages via apt
  package: 
    name={{ item }} state=absent
  with_items: "{{ purge_packages }}"
  become: True

- name: Remove python packages via pip
  pip:
    name: "{{ item }}" 
    state: absent 
    executable: pip3
  with_items: "{{ purge_pip_packages }}"
  become: True

- name: Install python packages via apt
  package: 
    name={{ item }} state=present
  with_items: "{{ packages }}"
  ignore_errors: True
  become: True

- name: Install python packages via pip
  pip:
    name={{ item }} state=latest executable=pip3
  with_items: "{{ pip_packages }}"
  become: True
  ignore_errors: True

- name: Ensure ptpython folder exists
  file:
    dest={{ ansible_env.HOME }}/.ptpython/
    state=directory
  become: False

- name: Ptipython config file
  file:
    dest={{ ansible_env.HOME }}/.ptpython/config.py
    state=absent
  become: False

- name: Purge python packages via apt
  package: 
    name={{ item }} state=absent
  with_items: "{{ purge_packages }}"
  ignore_errors: True
  become: True

- name: Remove python packages via pip
  pip:
    name: "{{ item }}" 
    state: absent 
    executable: pip3
  with_items: "{{ purge_pip_packages }}"
  ignore_errors: True
  become: True

- name: Install python packages via apt
  package: 
    name={{ item }} state=present
  with_items: "{{ packages }}"
  ignore_errors: True
  become: True

- name: Install python packages via pip
  pip:
    name={{ item }} state=latest executable=pip3
  with_items: "{{ pip_packages }}"
  become: True
  ignore_errors: True

- name: Ensure ptpython folder exists
  file:
    dest={{ ansible_env.HOME }}/.ptpython/
    state=directory
  become: False

- name: Ptipython config file
  file:
    dest={{ ansible_env.HOME }}/.ptpython/config.py
    state=absent
  become: False

Add error support to remove python packages
Add error support to remove python packages
