2018-03-22 19:14:40 +01:00
|
|
|
- block:
|
|
|
|
- name: Install foo package version 1.0.0
|
|
|
|
apt:
|
|
|
|
name: foo=1.0.0
|
|
|
|
allow_unauthenticated: yes
|
|
|
|
register: apt_result
|
|
|
|
|
|
|
|
- name: Check install with dpkg
|
|
|
|
shell: dpkg-query -l foo
|
|
|
|
register: dpkg_result
|
|
|
|
|
|
|
|
- name: Check if install was successful
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "apt_result is success"
|
|
|
|
- "dpkg_result is success"
|
|
|
|
- "'1.0.0' in dpkg_result.stdout"
|
|
|
|
|
|
|
|
- name: Update to foo version 1.0.1
|
|
|
|
apt:
|
|
|
|
name: foo
|
|
|
|
state: latest
|
|
|
|
allow_unauthenticated: yes
|
|
|
|
register: apt_result
|
|
|
|
|
|
|
|
- name: Check install with dpkg
|
|
|
|
shell: dpkg-query -l foo
|
|
|
|
register: dpkg_result
|
|
|
|
|
|
|
|
- name: Check if install was successful
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "apt_result is success"
|
|
|
|
- "dpkg_result is success"
|
|
|
|
- "'1.0.1' in dpkg_result.stdout"
|
2018-11-14 12:12:57 +01:00
|
|
|
always:
|
|
|
|
- name: Clean up
|
|
|
|
apt:
|
|
|
|
name: foo
|
|
|
|
state: absent
|
|
|
|
allow_unauthenticated: yes
|
|
|
|
|
2018-03-22 19:14:40 +01:00
|
|
|
|
2018-11-14 12:12:57 +01:00
|
|
|
# https://github.com/ansible/ansible/issues/30638
|
|
|
|
- block:
|
|
|
|
- name: Fail to install foo=1.0.1 since foo is not installed and only_upgrade is set
|
2018-04-03 16:25:51 +02:00
|
|
|
apt:
|
2018-11-14 12:12:57 +01:00
|
|
|
name: foo=1.0.1
|
2019-04-16 17:42:53 +02:00
|
|
|
state: present
|
2018-11-14 12:12:57 +01:00
|
|
|
only_upgrade: yes
|
|
|
|
allow_unauthenticated: yes
|
|
|
|
ignore_errors: yes
|
|
|
|
register: apt_result
|
|
|
|
|
|
|
|
- name: Check that foo was not upgraded
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "apt_result is not changed"
|
|
|
|
|
|
|
|
- apt:
|
|
|
|
name: foo=1.0.0
|
|
|
|
allow_unauthenticated: yes
|
|
|
|
|
|
|
|
- name: Upgrade foo to 1.0.1
|
|
|
|
apt:
|
|
|
|
name: foo=1.0.1
|
2019-04-16 17:42:53 +02:00
|
|
|
state: present
|
2018-11-14 12:12:57 +01:00
|
|
|
only_upgrade: yes
|
|
|
|
allow_unauthenticated: yes
|
|
|
|
register: apt_result
|
|
|
|
|
|
|
|
- name: Check install with dpkg
|
|
|
|
shell: dpkg-query -l foo
|
|
|
|
register: dpkg_result
|
|
|
|
|
|
|
|
- name: Check if install was successful
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "apt_result is success"
|
|
|
|
- "dpkg_result is success"
|
|
|
|
- "'1.0.1' in dpkg_result.stdout"
|
|
|
|
always:
|
|
|
|
- name: Clean up
|
|
|
|
apt:
|
|
|
|
name: foo
|
|
|
|
state: absent
|
|
|
|
allow_unauthenticated: yes
|
|
|
|
|
|
|
|
|
|
|
|
# https://github.com/ansible/ansible/issues/35900
|
|
|
|
- block:
|
|
|
|
- name: Disable ubuntu repos so system packages are not upgraded and do not change testing env
|
|
|
|
command: mv /etc/apt/sources.list /etc/apt/sources.list.backup
|
2018-04-03 16:25:51 +02:00
|
|
|
|
|
|
|
- name: Install foobar, installs foo as a dependency
|
|
|
|
apt:
|
|
|
|
name: foobar=1.0.0
|
|
|
|
allow_unauthenticated: yes
|
|
|
|
|
|
|
|
- name: Upgrade foobar to a version which does not depend on foo, autoremove should remove foo
|
|
|
|
apt:
|
|
|
|
upgrade: dist
|
|
|
|
autoremove: yes
|
2018-04-10 15:37:41 +02:00
|
|
|
allow_unauthenticated: yes
|
2018-04-03 16:25:51 +02:00
|
|
|
|
|
|
|
- name: Check foo with dpkg
|
|
|
|
shell: dpkg-query -l foo
|
|
|
|
register: dpkg_result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Check that foo was removed by autoremove
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "dpkg_result is failed"
|
|
|
|
|
2018-11-14 12:12:57 +01:00
|
|
|
always:
|
|
|
|
- name: Clean up
|
|
|
|
apt:
|
|
|
|
pkg: foo,foobar
|
|
|
|
state: absent
|
|
|
|
autoclean: yes
|
|
|
|
|
|
|
|
- name: Restore ubuntu repos
|
|
|
|
command: mv /etc/apt/sources.list.backup /etc/apt/sources.list
|
|
|
|
|
|
|
|
|
|
|
|
# https://github.com/ansible/ansible/issues/26298
|
|
|
|
- block:
|
|
|
|
- name: Disable ubuntu repos so system packages are not upgraded and do not change testing env
|
|
|
|
command: mv /etc/apt/sources.list /etc/apt/sources.list.backup
|
2018-04-09 11:10:42 +02:00
|
|
|
|
|
|
|
- name: Install foobar, installs foo as a dependency
|
|
|
|
apt:
|
|
|
|
name: foobar=1.0.0
|
|
|
|
allow_unauthenticated: yes
|
|
|
|
|
|
|
|
- name: Upgrade foobar to a version which does not depend on foo
|
|
|
|
apt:
|
|
|
|
upgrade: dist
|
|
|
|
force: yes # workaround for --allow-unauthenticated used along with upgrade
|
|
|
|
|
|
|
|
- name: autoremove should remove foo
|
|
|
|
apt:
|
|
|
|
autoremove: yes
|
|
|
|
register: autoremove_result
|
|
|
|
|
|
|
|
- name: Check that autoremove correctly reports changed=True
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "autoremove_result is changed"
|
|
|
|
|
|
|
|
- name: Check foo with dpkg
|
|
|
|
shell: dpkg-query -l foo
|
|
|
|
register: dpkg_result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Check that foo was removed by autoremove
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "dpkg_result is failed"
|
|
|
|
|
|
|
|
- name: Nothing to autoremove
|
|
|
|
apt:
|
|
|
|
autoremove: yes
|
|
|
|
register: autoremove_result
|
|
|
|
|
|
|
|
- name: Check that autoremove correctly reports changed=False
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "autoremove_result is not changed"
|
|
|
|
|
|
|
|
- name: Create a fake .deb file for autoclean to remove
|
|
|
|
file:
|
|
|
|
name: /var/cache/apt/archives/python3-q_2.4-1_all.deb
|
|
|
|
state: touch
|
|
|
|
|
|
|
|
- name: autoclean fake .deb file
|
|
|
|
apt:
|
|
|
|
autoclean: yes
|
|
|
|
register: autoclean_result
|
|
|
|
|
|
|
|
- name: Check if the .deb file exists
|
|
|
|
stat:
|
|
|
|
path: /var/cache/apt/archives/python3-q_2.4-1_all.deb
|
|
|
|
register: stat_result
|
|
|
|
|
|
|
|
- name: Check that autoclean correctly reports changed=True and file was removed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "autoclean_result is changed"
|
|
|
|
- "not stat_result.stat.exists"
|
|
|
|
|
|
|
|
- name: Nothing to autoclean
|
|
|
|
apt:
|
|
|
|
autoclean: yes
|
|
|
|
register: autoclean_result
|
|
|
|
|
|
|
|
- name: Check that autoclean correctly reports changed=False
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "autoclean_result is not changed"
|
|
|
|
|
2018-11-14 12:12:57 +01:00
|
|
|
always:
|
|
|
|
- name: Clean up
|
|
|
|
apt:
|
|
|
|
pkg: foo,foobar
|
|
|
|
state: absent
|
|
|
|
autoclean: yes
|
2018-04-17 10:17:29 +02:00
|
|
|
|
2018-11-14 12:12:57 +01:00
|
|
|
- name: Restore ubuntu repos
|
|
|
|
command: mv /etc/apt/sources.list.backup /etc/apt/sources.list
|
2018-04-17 10:17:29 +02:00
|
|
|
|
|
|
|
|
2018-11-14 12:12:57 +01:00
|
|
|
- name: Upgrades
|
|
|
|
block:
|
2020-09-29 17:35:59 +02:00
|
|
|
- import_tasks: "upgrade.yml"
|
|
|
|
vars:
|
|
|
|
aptitude_present: "{{ True | bool }}"
|
|
|
|
upgrade_type: "dist"
|
|
|
|
force_apt_get: "{{ False | bool }}"
|
2018-04-17 10:17:29 +02:00
|
|
|
|
2018-11-14 12:12:57 +01:00
|
|
|
- name: Check if aptitude is installed
|
|
|
|
command: dpkg-query --show --showformat='${db:Status-Abbrev}' aptitude
|
|
|
|
register: aptitude_status
|
2018-04-17 10:17:29 +02:00
|
|
|
|
2018-11-14 12:12:57 +01:00
|
|
|
- name: Remove aptitude, if installed, to test fall-back to apt-get
|
2018-03-22 19:14:40 +01:00
|
|
|
apt:
|
2018-11-14 12:12:57 +01:00
|
|
|
pkg: aptitude
|
2018-03-22 19:14:40 +01:00
|
|
|
state: absent
|
2018-11-14 12:12:57 +01:00
|
|
|
when:
|
|
|
|
- aptitude_status.stdout.find('ii') != -1
|
|
|
|
|
2020-09-29 17:35:59 +02:00
|
|
|
- include_tasks: "upgrade.yml"
|
|
|
|
vars:
|
|
|
|
aptitude_present: "{{ False | bool }}"
|
|
|
|
upgrade_type: "{{ item.upgrade_type }}"
|
|
|
|
force_apt_get: "{{ item.force_apt_get }}"
|
2018-04-03 16:25:51 +02:00
|
|
|
with_items:
|
2018-11-14 12:12:57 +01:00
|
|
|
- { upgrade_type: safe, force_apt_get: False }
|
|
|
|
- { upgrade_type: full, force_apt_get: False }
|
|
|
|
- { upgrade_type: safe, force_apt_get: True }
|
|
|
|
- { upgrade_type: full, force_apt_get: True }
|
|
|
|
|
|
|
|
- name: (Re-)Install aptitude, run same tests again
|
|
|
|
apt:
|
|
|
|
pkg: aptitude
|
|
|
|
state: present
|
|
|
|
|
2020-09-29 17:35:59 +02:00
|
|
|
- include_tasks: "upgrade.yml"
|
|
|
|
vars:
|
|
|
|
aptitude_present: "{{ True | bool }}"
|
|
|
|
upgrade_type: "{{ item.upgrade_type }}"
|
|
|
|
force_apt_get: "{{ item.force_apt_get }}"
|
2018-11-14 12:12:57 +01:00
|
|
|
with_items:
|
|
|
|
- { upgrade_type: safe, force_apt_get: False }
|
|
|
|
- { upgrade_type: full, force_apt_get: False }
|
|
|
|
- { upgrade_type: safe, force_apt_get: True }
|
|
|
|
- { upgrade_type: full, force_apt_get: True }
|
|
|
|
|
|
|
|
- name: Remove aptitude if not originally present
|
|
|
|
apt:
|
|
|
|
pkg: aptitude
|
|
|
|
state: absent
|
|
|
|
when:
|
|
|
|
- aptitude_status.stdout.find('ii') == -1
|