mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
152 lines
3.5 KiB
YAML
152 lines
3.5 KiB
YAML
- 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"
|
|
|
|
# https://github.com/ansible/ansible/issues/35900
|
|
- name: Clean up
|
|
apt:
|
|
name: foo
|
|
state: absent
|
|
|
|
- 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
|
|
force: yes # workaround for --allow-unauthenticated used along with upgrade
|
|
|
|
- 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"
|
|
|
|
# https://github.com/ansible/ansible/issues/26298
|
|
- name: Clean up
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
with_items:
|
|
- foo
|
|
- foobar
|
|
|
|
- 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"
|
|
|
|
always:
|
|
- name: Clean up
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
allow_unauthenticated: yes
|
|
with_items:
|
|
- foo
|
|
- foobar
|