Debian Codegraph @

test/integration/targets/dpkg_selections/tasks/dpkg_selections.yaml

raw
1 - name: get the default arch
2 command: dpkg --print-architecture
3 register: default_arch
4
5 - name: download and install old version of hello
6 apt: "deb=https://ci-files.testing.ansible.com/test/integration/targets/dpkg_selections/hello_{{ hello_old_version }}_{{ default_arch.stdout }}.deb"
7
8 - name: freeze version for hello
9 dpkg_selections:
10 name: hello
11 selection: hold
12
13 - name: get dpkg selections
14 shell: "dpkg --get-selections | grep hold"
15 register: result
16
17 - debug: var=result
18
19 - name: check that hello is marked as hold
20 assert:
21 that:
22 - "'hello' in result.stdout"
23
24 - name: attempt to upgrade hello
25 apt:
26 name: hello
27 state: latest
28 ignore_errors: yes
29
30 - name: check hello version
31 shell: dpkg -s hello | grep Version | awk '{print $2}'
32 register: hello_version
33
34 - name: ensure hello was not upgraded
35 assert:
36 that:
37 - hello_version.stdout == hello_old_version
38
39 - name: remove version freeze
40 dpkg_selections:
41 name: hello
42 selection: install
43
44 - name: upgrade hello
45 apt:
46 name: hello
47 state: latest
48
49 - name: check hello version
50 shell: dpkg -s hello | grep Version | awk '{print $2}'
51 register: hello_version
52
53 - name: check that old version upgraded correctly
54 assert:
55 that:
56 - hello_version.stdout != hello_old_version
57
58 - name: set hello to deinstall
59 dpkg_selections:
60 name: hello
61 selection: deinstall
62
63 - name: get dpkg selections
64 shell: "dpkg --get-selections | grep deinstall"
65 register: result
66
67 - debug: var=result
68
69 - name: check that hello is marked as deinstall
70 assert:
71 that:
72 - "'hello' in result.stdout"
73
74 - name: set hello to purge
75 dpkg_selections:
76 name: hello
77 selection: purge
78
79 - name: get dpkg selections
80 shell: "dpkg --get-selections | grep purge"
81 register: result
82
83 - debug: var=result
84
85 - name: check that hello is marked as purge
86 assert:
87 that:
88 - "'hello' in result.stdout"
89
90 - name: remove hello
91 apt:
92 name: hello
93 state: absent
94
95 - name: Try to select non-existent package
96 dpkg_selections:
97 name: kernel
98 selection: hold
99 ignore_errors: yes
100 register: result
101
102 - name: Check that module fails for non-existent package
103 assert:
104 that:
105 - "'Failed to find package' in result.msg"