mirror of https://github.com/ansible/ansible.git
apt: disable ubuntu repos to not change test env
(cherry picked from commit 0c86df33a4
)
pull/48736/head
parent
373e91fcf0
commit
82baf1c746
@ -1,61 +1,72 @@
|
|||||||
---
|
- block:
|
||||||
#### Tests for upgrade/download functions in modules/packaging/os/apt.py ####
|
- name: Disable ubuntu repos so system packages are not upgraded and do not change testing env
|
||||||
- name: download and install old version of hello
|
command: mv /etc/apt/sources.list /etc/apt/sources.list.backup
|
||||||
apt: "deb=https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/apt/hello_{{ hello_old_version }}_amd64.deb"
|
|
||||||
|
- name: install foo-1.0.0
|
||||||
- name: check hello version
|
apt:
|
||||||
shell: dpkg -s hello | grep Version | awk '{print $2}'
|
name: foo=1.0.0
|
||||||
register: hello_version
|
state: present
|
||||||
|
allow_unauthenticated: yes
|
||||||
- name: ensure the correct version of hello has been installed
|
|
||||||
assert:
|
- name: check foo version
|
||||||
that:
|
shell: dpkg -s foo | grep Version | awk '{print $2}'
|
||||||
- "{{ hello_version.stdout }}=={{ hello_old_version }}"
|
register: foo_version
|
||||||
|
|
||||||
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version, force_apt_get: {{force_apt_get}}"
|
- name: ensure the correct version of foo has been installed
|
||||||
apt:
|
assert:
|
||||||
upgrade: "{{ upgrade_type }}"
|
that:
|
||||||
force_apt_get: "{{ force_apt_get }}"
|
- "'1.0.0' in foo_version.stdout"
|
||||||
register: upgrade_result
|
|
||||||
|
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version, force_apt_get: {{force_apt_get}}"
|
||||||
- name: check hello version
|
apt:
|
||||||
shell: dpkg -s hello | grep Version | awk '{print $2}'
|
upgrade: "{{ upgrade_type }}"
|
||||||
register: hello_version
|
force_apt_get: "{{ force_apt_get }}"
|
||||||
|
force: yes
|
||||||
- name: check that warning is not given when force_apt_get set
|
register: upgrade_result
|
||||||
assert:
|
|
||||||
that:
|
- name: check foo version
|
||||||
- "'warnings' not in upgrade_result"
|
shell: dpkg -s foo | grep Version | awk '{print $2}'
|
||||||
when:
|
register: foo_version
|
||||||
- force_apt_get
|
|
||||||
|
- name: check that warning is not given when force_apt_get set
|
||||||
- name: check that warning is given when aptitude not found and force_apt_get not set
|
assert:
|
||||||
assert:
|
that:
|
||||||
that:
|
- "'warnings' not in upgrade_result"
|
||||||
- "'Could not find aptitude. Using apt-get instead' in upgrade_result.warnings[0]"
|
when:
|
||||||
when:
|
- force_apt_get
|
||||||
- not aptitude_present
|
|
||||||
- not force_apt_get
|
- name: check that warning is given when aptitude not found and force_apt_get not set
|
||||||
|
assert:
|
||||||
- name: check that old version upgraded correctly
|
that:
|
||||||
assert:
|
- "'Could not find aptitude. Using apt-get instead' in upgrade_result.warnings[0]"
|
||||||
that:
|
when:
|
||||||
- "{{ hello_version.stdout }}!={{ hello_old_version }}"
|
- not aptitude_present
|
||||||
- "{{ hello_version.changed }}"
|
- not force_apt_get
|
||||||
|
|
||||||
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version (Idempotant)"
|
- name: check that old version upgraded correctly
|
||||||
apt:
|
assert:
|
||||||
upgrade: "{{ upgrade_type }}"
|
that:
|
||||||
force_apt_get: "{{ force_apt_get }}"
|
- "'1.0.0' not in foo_version.stdout"
|
||||||
register: second_upgrade_result
|
- "{{ foo_version.changed }}"
|
||||||
|
|
||||||
- name: check that nothing has changed (Idempotant)
|
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version (Idempotant)"
|
||||||
assert:
|
apt:
|
||||||
that:
|
upgrade: "{{ upgrade_type }}"
|
||||||
- "second_upgrade_result.changed == false"
|
force_apt_get: "{{ force_apt_get }}"
|
||||||
|
force: yes
|
||||||
- name: remove hello
|
register: second_upgrade_result
|
||||||
apt:
|
|
||||||
pkg: hello
|
- name: check that nothing has changed (Idempotant)
|
||||||
state: absent
|
assert:
|
||||||
autoclean: yes
|
that:
|
||||||
|
- "second_upgrade_result.changed == false"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Clean up
|
||||||
|
apt:
|
||||||
|
pkg: foo,foobar
|
||||||
|
state: absent
|
||||||
|
autoclean: yes
|
||||||
|
|
||||||
|
- name: Restore ubuntu repos
|
||||||
|
command: mv /etc/apt/sources.list.backup /etc/apt/sources.list
|
||||||
|
Loading…
Reference in New Issue