summaryrefslogtreecommitdiff
path: root/test/integration/targets/dpkg_selections/tasks/dpkg_selections.yaml
blob: 016d7716d03247412372cfa29c9caecfcdff0ae0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
- name: download and install old version of hello
  apt: "deb=https://ci-files.testing.ansible.com/test/integration/targets/dpkg_selections/hello_{{ hello_old_version }}_amd64.deb"

- name: freeze version for hello
  dpkg_selections:
    name: hello
    selection: hold

- name: get dpkg selections
  shell: "dpkg --get-selections | grep hold"
  register: result

- debug: var=result

- name: check that hello is marked as hold
  assert:
    that:
      - "'hello' in result.stdout"

- name: attempt to upgrade hello
  apt:
    name: hello
    state: latest
  ignore_errors: yes

- name: check hello version
  shell: dpkg -s hello | grep Version | awk '{print $2}'
  register: hello_version

- name: ensure hello was not upgraded
  assert:
    that:
    - hello_version.stdout == hello_old_version

- name: remove version freeze
  dpkg_selections:
    name: hello
    selection: install

- name: upgrade hello
  apt:
    name: hello
    state: latest

- name: check hello version
  shell: dpkg -s hello | grep Version | awk '{print $2}'
  register: hello_version

- name: check that old version upgraded correctly
  assert:
    that:
    - hello_version.stdout != hello_old_version

- name: set hello to deinstall
  dpkg_selections:
    name: hello
    selection: deinstall

- name: get dpkg selections
  shell: "dpkg --get-selections | grep deinstall"
  register: result

- debug: var=result

- name: check that hello is marked as deinstall
  assert:
    that:
      - "'hello' in result.stdout"

- name: set hello to purge
  dpkg_selections:
    name: hello
    selection: purge

- name: get dpkg selections
  shell: "dpkg --get-selections | grep purge"
  register: result

- debug: var=result

- name: check that hello is marked as purge
  assert:
    that:
      - "'hello' in result.stdout"

- name: remove hello
  apt:
    name: hello
    state: absent

- name: Try to select non-existent package
  dpkg_selections:
    name: kernel
    selection: hold
  ignore_errors: yes
  register: result

- name: Check that module fails for non-existent package
  assert:
    that:
      - "'Failed to find package' in result.msg"