Path: blob/devel/test/integration/targets/apt/tasks/repo.yml
4751 views
- block:1- name: Install foo package version 1.0.02apt:3name: foo=1.0.04allow_unauthenticated: yes5register: apt_result67- name: Check install with dpkg8shell: dpkg-query -l foo9register: dpkg_result1011- name: Check if install was successful12assert:13that:14- "apt_result is success"15- "dpkg_result is success"16- "'1.0.0' in dpkg_result.stdout"1718- name: Update to foo version 1.0.119apt:20name: foo21state: latest22allow_unauthenticated: yes23register: apt_result2425- name: Check install with dpkg26shell: dpkg-query -l foo27register: dpkg_result2829- name: Check if install was successful30assert:31that:32- "apt_result is success"33- "dpkg_result is success"34- "'1.0.1' in dpkg_result.stdout"35always:36- name: Clean up37apt:38name: foo39state: absent40allow_unauthenticated: yes414243# https://github.com/ansible/ansible/issues/3063844- block:45- name: Fail to install foo=1.0.1 since foo is not installed and only_upgrade is set46apt:47name: foo=1.0.148state: present49only_upgrade: yes50allow_unauthenticated: yes51ignore_errors: yes52register: apt_result5354- name: Check that foo was not upgraded55assert:56that:57- "apt_result is not changed"5859- apt:60name: foo=1.0.061allow_unauthenticated: yes6263- name: Upgrade foo to 1.0.164apt:65name: foo=1.0.166state: present67only_upgrade: yes68allow_unauthenticated: yes69register: apt_result7071- name: Check install with dpkg72shell: dpkg-query -l foo73register: dpkg_result7475- name: Check if install was successful76assert:77that:78- "apt_result is success"79- "dpkg_result is success"80- "'1.0.1' in dpkg_result.stdout"81always:82- name: Clean up83apt:84name: foo85state: absent86allow_unauthenticated: yes878889# https://github.com/ansible/ansible/issues/3590090- block:91- name: Disable ubuntu repos so system packages are not upgraded and do not change testing env92command: mv /etc/apt/sources.list /etc/apt/sources.list.backup9394- name: Install foobar, installs foo as a dependency95apt:96name: foobar=1.0.097allow_unauthenticated: yes9899- name: Upgrade foobar to a version which does not depend on foo, autoremove should remove foo100apt:101upgrade: dist102autoremove: yes103allow_unauthenticated: yes104105- name: Check foo with dpkg106shell: dpkg-query -l foo107register: dpkg_result108ignore_errors: yes109110- name: Check that foo was removed by autoremove111assert:112that:113- "dpkg_result is failed"114115always:116- name: Clean up117apt:118pkg: foo,foobar119state: absent120autoclean: yes121122- name: Restore ubuntu repos123command: mv /etc/apt/sources.list.backup /etc/apt/sources.list124125126# https://github.com/ansible/ansible/issues/26298127- block:128- name: Disable ubuntu repos so system packages are not upgraded and do not change testing env129command: mv /etc/apt/sources.list /etc/apt/sources.list.backup130131- name: Install foobar, installs foo as a dependency132apt:133name: foobar=1.0.0134allow_unauthenticated: yes135136- name: Upgrade foobar to a version which does not depend on foo137apt:138upgrade: dist139force: yes # workaround for --allow-unauthenticated used along with upgrade140141- name: autoremove should remove foo142apt:143autoremove: yes144register: autoremove_result145146- name: Check that autoremove correctly reports changed=True147assert:148that:149- "autoremove_result is changed"150151- name: Check foo with dpkg152shell: dpkg-query -l foo153register: dpkg_result154ignore_errors: yes155156- name: Check that foo was removed by autoremove157assert:158that:159- "dpkg_result is failed"160161- name: Nothing to autoremove162apt:163autoremove: yes164register: autoremove_result165166- name: Check that autoremove correctly reports changed=False167assert:168that:169- "autoremove_result is not changed"170171- name: Create a fake .deb file for autoclean to remove172file:173name: /var/cache/apt/archives/python3-q_2.4-1_all.deb174state: touch175176- name: autoclean fake .deb file177apt:178autoclean: yes179register: autoclean_result180181- name: Check if the .deb file exists182stat:183path: /var/cache/apt/archives/python3-q_2.4-1_all.deb184register: stat_result185186- name: Check that autoclean correctly reports changed=True and file was removed187assert:188that:189- "autoclean_result is changed"190- "not stat_result.stat.exists"191192- name: Nothing to autoclean193apt:194autoclean: yes195register: autoclean_result196197- name: Check that autoclean correctly reports changed=False198assert:199that:200- "autoclean_result is not changed"201202always:203- name: Clean up204apt:205pkg: foo,foobar206state: absent207autoclean: yes208209- name: Restore ubuntu repos210command: mv /etc/apt/sources.list.backup /etc/apt/sources.list211212213- name: Upgrades214block:215- include: "upgrade.yml aptitude_present={{ True | bool }} upgrade_type=dist force_apt_get={{ False | bool }}"216217- name: Check if aptitude is installed218command: dpkg-query --show --showformat='${db:Status-Abbrev}' aptitude219register: aptitude_status220221- name: Remove aptitude, if installed, to test fall-back to apt-get222apt:223pkg: aptitude224state: absent225when:226- aptitude_status.stdout.find('ii') != -1227228- include: "upgrade.yml aptitude_present={{ False | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"229with_items:230- { upgrade_type: safe, force_apt_get: False }231- { upgrade_type: full, force_apt_get: False }232- { upgrade_type: safe, force_apt_get: True }233- { upgrade_type: full, force_apt_get: True }234235- name: (Re-)Install aptitude, run same tests again236apt:237pkg: aptitude238state: present239240- include: "upgrade.yml aptitude_present={{ True | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"241with_items:242- { upgrade_type: safe, force_apt_get: False }243- { upgrade_type: full, force_apt_get: False }244- { upgrade_type: safe, force_apt_get: True }245- { upgrade_type: full, force_apt_get: True }246247- name: Remove aptitude if not originally present248apt:249pkg: aptitude250state: absent251when:252- aptitude_status.stdout.find('ii') == -1253254255