mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
apt: allow for integration tests using fake repo (#37639)
* apt: allow for integration tests using fake repo * Add integration test for 19102 * Clean up packages and repo * Fix indentation
This commit is contained in:
parent
3a5a0fed06
commit
296ad80002
6 changed files with 110 additions and 0 deletions
|
@ -1,2 +1,3 @@
|
|||
dependencies:
|
||||
- prepare_tests
|
||||
- setup_deb_repo
|
||||
|
|
|
@ -18,6 +18,17 @@
|
|||
- include: 'apt.yml'
|
||||
when: ansible_distribution in ('Ubuntu', 'Debian')
|
||||
|
||||
- block:
|
||||
- include: 'repo.yml'
|
||||
always:
|
||||
- apt_repository:
|
||||
repo: "deb file:{{ repodir }} ./"
|
||||
state: absent
|
||||
- file:
|
||||
name: "{{ repodir }}"
|
||||
state: absent
|
||||
when: ansible_distribution in ('Ubuntu', 'Debian')
|
||||
|
||||
- include: 'apt-multiarch.yml'
|
||||
when: ansible_distribution in ('Ubuntu', 'Debian') and ansible_userspace_architecture != apt_foreign_arch
|
||||
|
||||
|
|
42
test/integration/targets/apt/tasks/repo.yml
Normal file
42
test/integration/targets/apt/tasks/repo.yml
Normal file
|
@ -0,0 +1,42 @@
|
|||
- block:
|
||||
- name: Install foo package version 1.0.0
|
||||
apt:
|
||||
name: foo=1.0.0
|
||||
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.0' in dpkg_result.stdout"
|
||||
|
||||
- name: Update to foo version 1.0.1
|
||||
apt:
|
||||
name: foo
|
||||
state: latest
|
||||
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
|
|
@ -0,0 +1,10 @@
|
|||
Section: misc
|
||||
Priority: optional
|
||||
Standards-Version: 2.3.3
|
||||
|
||||
Package: foo
|
||||
Version: 1.0.0
|
||||
Section: system
|
||||
Maintainer: John Doe <john@doe.com>
|
||||
Architecture: all
|
||||
Description: Dummy package
|
|
@ -0,0 +1,10 @@
|
|||
Section: misc
|
||||
Priority: optional
|
||||
Standards-Version: 2.3.3
|
||||
|
||||
Package: foo
|
||||
Version: 1.0.1
|
||||
Section: system
|
||||
Maintainer: John Doe <john@doe.com>
|
||||
Architecture: all
|
||||
Description: Dummy package
|
36
test/integration/targets/setup_deb_repo/tasks/main.yml
Normal file
36
test/integration/targets/setup_deb_repo/tasks/main.yml
Normal file
|
@ -0,0 +1,36 @@
|
|||
- block:
|
||||
- name: Install needed packages
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
with_items:
|
||||
- dpkg-dev
|
||||
- equivs
|
||||
- libfile-fcntllock-perl # to silence warning by equivs-build
|
||||
|
||||
- set_fact:
|
||||
repodir: /tmp/repo/
|
||||
|
||||
- name: Create repo dir
|
||||
file:
|
||||
path: "{{ repodir }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: Create deb files
|
||||
shell: "equivs-build {{ item }}"
|
||||
args:
|
||||
chdir: "{{ repodir }}"
|
||||
with_fileglob:
|
||||
- "files/package_specs/*"
|
||||
|
||||
- name: Create repo
|
||||
shell: dpkg-scanpackages --multiversion . /dev/null | gzip -9c > Packages.gz
|
||||
args:
|
||||
chdir: "{{ repodir }}"
|
||||
|
||||
- name: Install the repo
|
||||
apt_repository:
|
||||
repo: "deb file:{{ repodir }} ./"
|
||||
validate_certs: no
|
||||
|
||||
when: ansible_distribution in ['Ubuntu', 'Debian']
|
Loading…
Reference in a new issue