1
0
Fork 0
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:
Martin Krizek 2018-03-22 19:14:40 +01:00 committed by GitHub
parent 3a5a0fed06
commit 296ad80002
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 110 additions and 0 deletions

View file

@ -1,2 +1,3 @@
dependencies:
- prepare_tests
- setup_deb_repo

View file

@ -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

View 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

View file

@ -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

View file

@ -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

View 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']