|
|
|
@ -1,15 +1,26 @@
|
|
|
|
|
- name: show python version
|
|
|
|
|
debug: var=ansible_python_version
|
|
|
|
|
|
|
|
|
|
- name: use python-apt
|
|
|
|
|
set_fact:
|
|
|
|
|
python_apt: python-apt
|
|
|
|
|
when: ansible_python_version | version_compare('3', '<')
|
|
|
|
|
|
|
|
|
|
- name: use python3-apt
|
|
|
|
|
set_fact:
|
|
|
|
|
python_apt: python3-apt
|
|
|
|
|
when: ansible_python_version | version_compare('3', '>=')
|
|
|
|
|
|
|
|
|
|
# UNINSTALL 'python-apt'
|
|
|
|
|
# The `apt` module has the smarts to auto-install `python-apt`. To test, we
|
|
|
|
|
# will first uninstall `python-apt`.
|
|
|
|
|
- name: check python-apt with dpkg
|
|
|
|
|
shell: dpkg -s python-apt
|
|
|
|
|
- name: check {{ python_apt }} with dpkg
|
|
|
|
|
shell: dpkg -s {{ python_apt }}
|
|
|
|
|
register: dpkg_result
|
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
|
|
- name: uninstall python-apt with apt
|
|
|
|
|
apt: pkg=python-apt state=absent purge=yes
|
|
|
|
|
- name: uninstall {{ python_apt }} with apt
|
|
|
|
|
apt: pkg={{ python_apt }} state=absent purge=yes
|
|
|
|
|
register: apt_result
|
|
|
|
|
when: dpkg_result|success
|
|
|
|
|
|
|
|
|
|