apt: disable ubuntu repos to not change test env
(cherry picked from commit 0c86df33a4
)
This commit is contained in:
parent
373e91fcf0
commit
82baf1c746
4 changed files with 187 additions and 153 deletions
|
@ -1,2 +1 @@
|
||||||
apt_foreign_arch: i386
|
apt_foreign_arch: i386
|
||||||
hello_old_version: 2.6-1
|
|
||||||
|
|
|
@ -16,6 +16,14 @@
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
- include: 'apt.yml'
|
||||||
|
|
||||||
|
- include: 'apt-multiarch.yml'
|
||||||
|
when:
|
||||||
|
- ansible_userspace_architecture != apt_foreign_arch
|
||||||
|
|
||||||
|
- include: 'apt-builddep.yml'
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- include: 'repo.yml'
|
- include: 'repo.yml'
|
||||||
always:
|
always:
|
||||||
|
@ -26,52 +34,5 @@
|
||||||
name: "{{ repodir }}"
|
name: "{{ repodir }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- include: 'apt.yml'
|
|
||||||
|
|
||||||
- include: 'apt-multiarch.yml'
|
|
||||||
when:
|
|
||||||
- ansible_userspace_architecture != apt_foreign_arch
|
|
||||||
|
|
||||||
- include: 'apt-builddep.yml'
|
|
||||||
|
|
||||||
- include: "upgrade.yml aptitude_present={{ True | bool }} upgrade_type=dist force_apt_get={{ False | bool }}"
|
|
||||||
|
|
||||||
- name: Check if aptitude is installed
|
|
||||||
command: dpkg-query --show --showformat='${db:Status-Abbrev}' aptitude
|
|
||||||
register: aptitude_status
|
|
||||||
|
|
||||||
- name: Remove aptitude, if installed, to test fall-back to apt-get
|
|
||||||
apt:
|
|
||||||
pkg: aptitude
|
|
||||||
state: absent
|
|
||||||
when:
|
|
||||||
- aptitude_status.stdout.find('ii') != -1
|
|
||||||
|
|
||||||
- include: "upgrade.yml aptitude_present={{ False | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"
|
|
||||||
with_items:
|
|
||||||
- { upgrade_type: safe, force_apt_get: False }
|
|
||||||
- { upgrade_type: full, force_apt_get: False }
|
|
||||||
- { upgrade_type: safe, force_apt_get: True }
|
|
||||||
- { upgrade_type: full, force_apt_get: True }
|
|
||||||
|
|
||||||
- name: (Re-)Install aptitude, run same tests again
|
|
||||||
apt:
|
|
||||||
pkg: aptitude
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- include: "upgrade.yml aptitude_present={{ True | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"
|
|
||||||
with_items:
|
|
||||||
- { upgrade_type: safe, force_apt_get: False }
|
|
||||||
- { upgrade_type: full, force_apt_get: False }
|
|
||||||
- { upgrade_type: safe, force_apt_get: True }
|
|
||||||
- { upgrade_type: full, force_apt_get: True }
|
|
||||||
|
|
||||||
- name: Remove aptitude if not originally present
|
|
||||||
apt:
|
|
||||||
pkg: aptitude
|
|
||||||
state: absent
|
|
||||||
when:
|
|
||||||
- aptitude_status.stdout.find('ii') == -1
|
|
||||||
|
|
||||||
when:
|
when:
|
||||||
- ansible_distribution in ('Ubuntu', 'Debian')
|
- ansible_distribution in ('Ubuntu', 'Debian')
|
||||||
|
|
|
@ -33,12 +33,64 @@
|
||||||
- "apt_result is success"
|
- "apt_result is success"
|
||||||
- "dpkg_result is success"
|
- "dpkg_result is success"
|
||||||
- "'1.0.1' in dpkg_result.stdout"
|
- "'1.0.1' in dpkg_result.stdout"
|
||||||
|
always:
|
||||||
|
- name: Clean up
|
||||||
|
apt:
|
||||||
|
name: foo
|
||||||
|
state: absent
|
||||||
|
allow_unauthenticated: yes
|
||||||
|
|
||||||
# https://github.com/ansible/ansible/issues/35900
|
|
||||||
- name: Clean up
|
# https://github.com/ansible/ansible/issues/30638
|
||||||
|
- block:
|
||||||
|
- name: Fail to install foo=1.0.1 since foo is not installed and only_upgrade is set
|
||||||
apt:
|
apt:
|
||||||
name: foo
|
name: foo=1.0.1
|
||||||
state: absent
|
state: installed
|
||||||
|
only_upgrade: yes
|
||||||
|
allow_unauthenticated: yes
|
||||||
|
ignore_errors: yes
|
||||||
|
register: apt_result
|
||||||
|
|
||||||
|
- name: Check that foo was not upgraded
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "apt_result is not changed"
|
||||||
|
|
||||||
|
- apt:
|
||||||
|
name: foo=1.0.0
|
||||||
|
allow_unauthenticated: yes
|
||||||
|
|
||||||
|
- name: Upgrade foo to 1.0.1
|
||||||
|
apt:
|
||||||
|
name: foo=1.0.1
|
||||||
|
state: installed
|
||||||
|
only_upgrade: yes
|
||||||
|
allow_unauthenticated: yes
|
||||||
|
register: apt_result
|
||||||
|
|
||||||
|
- name: Check install with dpkg
|
||||||
|
shell: dpkg-query -l foo
|
||||||
|
register: dpkg_result
|
||||||
|
|
||||||
|
- name: Check if install was successful
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "apt_result is success"
|
||||||
|
- "dpkg_result is success"
|
||||||
|
- "'1.0.1' in dpkg_result.stdout"
|
||||||
|
always:
|
||||||
|
- name: Clean up
|
||||||
|
apt:
|
||||||
|
name: foo
|
||||||
|
state: absent
|
||||||
|
allow_unauthenticated: yes
|
||||||
|
|
||||||
|
|
||||||
|
# https://github.com/ansible/ansible/issues/35900
|
||||||
|
- block:
|
||||||
|
- name: Disable ubuntu repos so system packages are not upgraded and do not change testing env
|
||||||
|
command: mv /etc/apt/sources.list /etc/apt/sources.list.backup
|
||||||
|
|
||||||
- name: Install foobar, installs foo as a dependency
|
- name: Install foobar, installs foo as a dependency
|
||||||
apt:
|
apt:
|
||||||
|
@ -61,14 +113,21 @@
|
||||||
that:
|
that:
|
||||||
- "dpkg_result is failed"
|
- "dpkg_result is failed"
|
||||||
|
|
||||||
# https://github.com/ansible/ansible/issues/26298
|
always:
|
||||||
- name: Clean up
|
- name: Clean up
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
pkg: foo,foobar
|
||||||
state: absent
|
state: absent
|
||||||
with_items:
|
autoclean: yes
|
||||||
- foo
|
|
||||||
- foobar
|
- name: Restore ubuntu repos
|
||||||
|
command: mv /etc/apt/sources.list.backup /etc/apt/sources.list
|
||||||
|
|
||||||
|
|
||||||
|
# https://github.com/ansible/ansible/issues/26298
|
||||||
|
- block:
|
||||||
|
- name: Disable ubuntu repos so system packages are not upgraded and do not change testing env
|
||||||
|
command: mv /etc/apt/sources.list /etc/apt/sources.list.backup
|
||||||
|
|
||||||
- name: Install foobar, installs foo as a dependency
|
- name: Install foobar, installs foo as a dependency
|
||||||
apt:
|
apt:
|
||||||
|
@ -141,50 +200,54 @@
|
||||||
that:
|
that:
|
||||||
- "autoclean_result is not changed"
|
- "autoclean_result is not changed"
|
||||||
|
|
||||||
# https://github.com/ansible/ansible/issues/30638
|
|
||||||
- name: Fail to install foo=1.0.1 since foo is not installed and only_upgrade is set
|
|
||||||
apt:
|
|
||||||
name: foo=1.0.1
|
|
||||||
state: installed
|
|
||||||
only_upgrade: yes
|
|
||||||
allow_unauthenticated: yes
|
|
||||||
ignore_errors: yes
|
|
||||||
register: apt_result
|
|
||||||
|
|
||||||
- name: Check that foo was not upgraded
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "apt_result is not changed"
|
|
||||||
|
|
||||||
- apt:
|
|
||||||
name: foo=1.0.0
|
|
||||||
allow_unauthenticated: yes
|
|
||||||
|
|
||||||
- name: Upgrade foo to 1.0.1
|
|
||||||
apt:
|
|
||||||
name: foo=1.0.1
|
|
||||||
state: installed
|
|
||||||
only_upgrade: yes
|
|
||||||
allow_unauthenticated: yes
|
|
||||||
register: apt_result
|
|
||||||
|
|
||||||
- name: Check install with dpkg
|
|
||||||
shell: dpkg-query -l foo
|
|
||||||
register: dpkg_result
|
|
||||||
|
|
||||||
- name: Check if install was successful
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "apt_result is success"
|
|
||||||
- "dpkg_result is success"
|
|
||||||
- "'1.0.1' in dpkg_result.stdout"
|
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Clean up
|
- name: Clean up
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
pkg: foo,foobar
|
||||||
state: absent
|
state: absent
|
||||||
allow_unauthenticated: yes
|
autoclean: yes
|
||||||
|
|
||||||
|
- name: Restore ubuntu repos
|
||||||
|
command: mv /etc/apt/sources.list.backup /etc/apt/sources.list
|
||||||
|
|
||||||
|
|
||||||
|
- name: Upgrades
|
||||||
|
block:
|
||||||
|
- include: "upgrade.yml aptitude_present={{ True | bool }} upgrade_type=dist force_apt_get={{ False | bool }}"
|
||||||
|
|
||||||
|
- name: Check if aptitude is installed
|
||||||
|
command: dpkg-query --show --showformat='${db:Status-Abbrev}' aptitude
|
||||||
|
register: aptitude_status
|
||||||
|
|
||||||
|
- name: Remove aptitude, if installed, to test fall-back to apt-get
|
||||||
|
apt:
|
||||||
|
pkg: aptitude
|
||||||
|
state: absent
|
||||||
|
when:
|
||||||
|
- aptitude_status.stdout.find('ii') != -1
|
||||||
|
|
||||||
|
- include: "upgrade.yml aptitude_present={{ False | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"
|
||||||
with_items:
|
with_items:
|
||||||
- foo
|
- { upgrade_type: safe, force_apt_get: False }
|
||||||
- foobar
|
- { upgrade_type: full, force_apt_get: False }
|
||||||
|
- { upgrade_type: safe, force_apt_get: True }
|
||||||
|
- { upgrade_type: full, force_apt_get: True }
|
||||||
|
|
||||||
|
- name: (Re-)Install aptitude, run same tests again
|
||||||
|
apt:
|
||||||
|
pkg: aptitude
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- include: "upgrade.yml aptitude_present={{ True | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"
|
||||||
|
with_items:
|
||||||
|
- { upgrade_type: safe, force_apt_get: False }
|
||||||
|
- { upgrade_type: full, force_apt_get: False }
|
||||||
|
- { upgrade_type: safe, force_apt_get: True }
|
||||||
|
- { upgrade_type: full, force_apt_get: True }
|
||||||
|
|
||||||
|
- name: Remove aptitude if not originally present
|
||||||
|
apt:
|
||||||
|
pkg: aptitude
|
||||||
|
state: absent
|
||||||
|
when:
|
||||||
|
- aptitude_status.stdout.find('ii') == -1
|
||||||
|
|
|
@ -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: check hello version
|
- name: install foo-1.0.0
|
||||||
shell: dpkg -s hello | grep Version | awk '{print $2}'
|
apt:
|
||||||
register: hello_version
|
name: foo=1.0.0
|
||||||
|
state: present
|
||||||
|
allow_unauthenticated: yes
|
||||||
|
|
||||||
- name: ensure the correct version of hello has been installed
|
- name: check foo version
|
||||||
assert:
|
shell: dpkg -s foo | grep Version | awk '{print $2}'
|
||||||
that:
|
register: foo_version
|
||||||
- "{{ hello_version.stdout }}=={{ hello_old_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: check hello version
|
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version, force_apt_get: {{force_apt_get}}"
|
||||||
shell: dpkg -s hello | grep Version | awk '{print $2}'
|
apt:
|
||||||
register: hello_version
|
upgrade: "{{ upgrade_type }}"
|
||||||
|
force_apt_get: "{{ force_apt_get }}"
|
||||||
|
force: yes
|
||||||
|
register: upgrade_result
|
||||||
|
|
||||||
- name: check that warning is not given when force_apt_get set
|
- name: check foo version
|
||||||
assert:
|
shell: dpkg -s foo | grep Version | awk '{print $2}'
|
||||||
that:
|
register: foo_version
|
||||||
- "'warnings' not in upgrade_result"
|
|
||||||
when:
|
|
||||||
- force_apt_get
|
|
||||||
|
|
||||||
- name: check that warning is given when aptitude not found and force_apt_get not set
|
- name: check that warning is not given when force_apt_get set
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'Could not find aptitude. Using apt-get instead' in upgrade_result.warnings[0]"
|
- "'warnings' not in upgrade_result"
|
||||||
when:
|
when:
|
||||||
- not aptitude_present
|
- force_apt_get
|
||||||
- not force_apt_get
|
|
||||||
|
|
||||||
- name: check that old version upgraded correctly
|
- name: check that warning is given when aptitude not found and force_apt_get not set
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "{{ hello_version.stdout }}!={{ hello_old_version }}"
|
- "'Could not find aptitude. Using apt-get instead' in upgrade_result.warnings[0]"
|
||||||
- "{{ hello_version.changed }}"
|
when:
|
||||||
|
- not aptitude_present
|
||||||
|
- 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
|
||||||
|
register: second_upgrade_result
|
||||||
|
|
||||||
- name: remove hello
|
- name: check that nothing has changed (Idempotant)
|
||||||
apt:
|
assert:
|
||||||
pkg: hello
|
that:
|
||||||
state: absent
|
- "second_upgrade_result.changed == false"
|
||||||
autoclean: yes
|
|
||||||
|
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 a new issue