Debian Codegraph @

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

raw ◀ ▶
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 shell: |
4 find /etc/apt/sources.list* \
5 \( -name \*.list -or -name \*.sources \) \
6 -and -not -name file_tmp_repo.list \
7 -and -not -name 'local_repo_*.sources' \
8 | xargs -I{} mv {} {}.backup
9
10 - name: install latest foo
11 apt:
12 name: foo
13 state: latest
14 allow_unauthenticated: yes
15
16 - name: check foo version
17 shell: dpkg -s foo | grep Version | awk '{print $2}'
18 register: apt_downgrade_foo_version
19
20 - name: ensure the correct version of foo has been installed
21 assert:
22 that:
23 - "'1.0.1' in apt_downgrade_foo_version.stdout"
24
25 - name: try to downgrade foo
26 apt:
27 name: foo=1.0.0
28 state: present
29 allow_unauthenticated: yes
30 ignore_errors: yes
31 register: apt_downgrade_foo_fail
32
33 - name: verify failure of downgrading without allow downgrade flag
34 assert:
35 that:
36 - apt_downgrade_foo_fail is failed
37
38 - name: try to downgrade foo with flag
39 apt:
40 name: foo=1.0.0
41 state: present
42 allow_downgrade: yes
43 allow_unauthenticated: yes
44 register: apt_downgrade_foo_succeed
45
46 - name: verify success of downgrading with allow downgrade flag
47 assert:
48 that:
49 - apt_downgrade_foo_succeed is success
50
51 - name: check foo version
52 shell: dpkg -s foo | grep Version | awk '{print $2}'
53 register: apt_downgrade_foo_version
54
55 - name: check that version downgraded correctly
56 assert:
57 that:
58 - "'1.0.0' in apt_downgrade_foo_version.stdout"
59 - "apt_downgrade_foo_version.changed"
60
61 - name: downgrade foo with flag again
62 apt:
63 name: foo=1.0.0
64 state: present
65 allow_downgrade: yes
66 allow_unauthenticated: yes
67 register: apt_downgrade_second_downgrade
68
69 - name: check that nothing has changed (idempotent)
70 assert:
71 that:
72 - "apt_downgrade_second_downgrade.changed == false"
73
74 always:
75 - name: Clean up
76 apt:
77 pkg: foo,foobar
78 state: absent
79 autoclean: yes
80
81 - name: Restore ubuntu repos
•82 shell: |
83 find /etc/apt/sources.list* -name \*.backup \
84 | sed 's/\.backup$//' \
85 | xargs -I{} mv {}.backup {}