Debian Codegraph @

test/integration/targets/apt/tasks/downgrade.yml

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 - block:
2 - name: Disable ubuntu repos so system packages are not upgraded and do not change testing env
3 command: mv /etc/apt/sources.list /etc/apt/sources.list.backup
4
5 - name: install latest foo
6 apt:
7 name: foo
8 state: latest
9 allow_unauthenticated: yes
10
11 - name: check foo version
12 shell: dpkg -s foo | grep Version | awk '{print $2}'
13 register: apt_downgrade_foo_version
14
15 - name: ensure the correct version of foo has been installed
16 assert:
17 that:
18 - "'1.0.1' in apt_downgrade_foo_version.stdout"
19
20 - name: try to downgrade foo
21 apt:
22 name: foo=1.0.0
23 state: present
24 allow_unauthenticated: yes
25 ignore_errors: yes
26 register: apt_downgrade_foo_fail
27
28 - name: verify failure of downgrading without allow downgrade flag
29 assert:
30 that:
31 - apt_downgrade_foo_fail is failed
32
33 - name: try to downgrade foo with flag
34 apt:
35 name: foo=1.0.0
36 state: present
37 allow_downgrade: yes
38 allow_unauthenticated: yes
39 register: apt_downgrade_foo_succeed
40
41 - name: verify success of downgrading with allow downgrade flag
42 assert:
43 that:
44 - apt_downgrade_foo_succeed is success
45
46 - name: check foo version
47 shell: dpkg -s foo | grep Version | awk '{print $2}'
48 register: apt_downgrade_foo_version
49
50 - name: check that version downgraded correctly
51 assert:
52 that:
53 - "'1.0.0' in apt_downgrade_foo_version.stdout"
54 - "apt_downgrade_foo_version.changed"
55
56 - name: downgrade foo with flag again
57 apt:
58 name: foo=1.0.0
59 state: present
60 allow_downgrade: yes
61 allow_unauthenticated: yes
62 register: apt_downgrade_second_downgrade
63
64 - name: check that nothing has changed (idempotent)
65 assert:
66 that:
67 - "apt_downgrade_second_downgrade.changed == false"
68
69 always:
70 - name: Clean up
71 apt:
72 pkg: foo,foobar
73 state: absent
74 autoclean: yes
75
76 - name: Restore ubuntu repos
77 command: mv /etc/apt/sources.list.backup /etc/apt/sources.list