diff --git a/test/integration/targets/apt/meta/main.yml b/test/integration/targets/apt/meta/main.yml index 07faa21776..162d7fab33 100644 --- a/test/integration/targets/apt/meta/main.yml +++ b/test/integration/targets/apt/meta/main.yml @@ -1,2 +1,3 @@ dependencies: - prepare_tests + - setup_deb_repo diff --git a/test/integration/targets/apt/tasks/main.yml b/test/integration/targets/apt/tasks/main.yml index 8ca7d921b8..4cb63a39ce 100644 --- a/test/integration/targets/apt/tasks/main.yml +++ b/test/integration/targets/apt/tasks/main.yml @@ -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 diff --git a/test/integration/targets/apt/tasks/repo.yml b/test/integration/targets/apt/tasks/repo.yml new file mode 100644 index 0000000000..e1263b0bb5 --- /dev/null +++ b/test/integration/targets/apt/tasks/repo.yml @@ -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 diff --git a/test/integration/targets/setup_deb_repo/files/package_specs/foo-1.0.0 b/test/integration/targets/setup_deb_repo/files/package_specs/foo-1.0.0 new file mode 100644 index 0000000000..4206fbabb9 --- /dev/null +++ b/test/integration/targets/setup_deb_repo/files/package_specs/foo-1.0.0 @@ -0,0 +1,10 @@ +Section: misc +Priority: optional +Standards-Version: 2.3.3 + +Package: foo +Version: 1.0.0 +Section: system +Maintainer: John Doe +Architecture: all +Description: Dummy package diff --git a/test/integration/targets/setup_deb_repo/files/package_specs/foo-1.0.1 b/test/integration/targets/setup_deb_repo/files/package_specs/foo-1.0.1 new file mode 100644 index 0000000000..021f4d523f --- /dev/null +++ b/test/integration/targets/setup_deb_repo/files/package_specs/foo-1.0.1 @@ -0,0 +1,10 @@ +Section: misc +Priority: optional +Standards-Version: 2.3.3 + +Package: foo +Version: 1.0.1 +Section: system +Maintainer: John Doe +Architecture: all +Description: Dummy package diff --git a/test/integration/targets/setup_deb_repo/tasks/main.yml b/test/integration/targets/setup_deb_repo/tasks/main.yml new file mode 100644 index 0000000000..84c0f909a3 --- /dev/null +++ b/test/integration/targets/setup_deb_repo/tasks/main.yml @@ -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']