blob: 1fec0cc79d7e99efb62ecac01daa0272219f564d (
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
|
---
#### Tests for upgrade/download functions in modules/packaging/os/apt.py ####
- name: download and install old version of hello
apt: "deb=https://launchpad.net/ubuntu/+archive/primary/+files/hello_{{ hello_old_version }}_amd64.deb"
- name: check hello version
shell: dpkg -s hello | grep Version | awk '{print $2}'
register: hello_version
- debug: var=hello_version
- name: ensure the correct version of hello has been installed
assert:
that:
- "{{ hello_version.stdout }}=={{ hello_old_version }}"
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version, force_apt_get: {{force_apt_get|default(False)}}"
apt:
upgrade: "{{ upgrade_type }}"
force_apt_get: "{{ force_apt_get | default(False) }}"
register: upgrade_result
- name: check hello version
shell: dpkg -s hello | grep Version | awk '{print $2}'
register: hello_version
- debug: var=upgrade_result.warnings|default([])
- debug: var=aptitude_present
- debug: var=force_apt_get
- name: check that warning is not given when force_apt_get set
assert:
that:
- "'Could not find aptitude. Using apt-get instead' not in upgrade_result.warnings | default([])"
when:
- force_apt_get | default(False)
- name: check that warning is given when aptitude not found and force_apt_get not set
assert:
that:
- "'Could not find aptitude. Using apt-get instead' in upgrade_result.warnings"
when:
- not aptitude_present|default(True)
- not force_apt_get|default(False)
- name: check that old version upgraded correctly
assert:
that:
- "{{ hello_version.stdout }}!={{ hello_old_version }}"
- "{{ hello_version.changed }}"
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version (Idempotant)"
apt:
upgrade: "{{ upgrade_type }}"
force_apt_get: "{{ force_apt_get | default(False) }}"
register: second_upgrade_result
- name: check that nothing has changed (Idempotant)
assert:
that:
- "second_upgrade_result.changed == false"
- name: remove hello
apt:
pkg: hello
state: absent
autoclean: yes
|