diff --git a/test/integration/targets/apt/aliases b/test/integration/targets/apt/aliases index 676400008d..c52a478d10 100644 --- a/test/integration/targets/apt/aliases +++ b/test/integration/targets/apt/aliases @@ -1,3 +1,4 @@ +posix/ci/group1 destructive skip/freebsd skip/osx diff --git a/test/integration/targets/apt/tasks/apt.yml b/test/integration/targets/apt/tasks/apt.yml index 4d01cead40..adebd17bdc 100644 --- a/test/integration/targets/apt/tasks/apt.yml +++ b/test/integration/targets/apt/tasks/apt.yml @@ -1,6 +1,3 @@ -- name: show python version - debug: var=ansible_python_version - - name: use python-apt set_fact: python_apt: python-apt @@ -62,9 +59,6 @@ failed_when: False register: dpkg_result -- debug: var=apt_result -- debug: var=dpkg_result - - name: verify installation of hello assert: that: @@ -104,9 +98,6 @@ failed_when: False register: dpkg_result -- debug: var=apt_result -- debug: var=dpkg_result - - name: verify installation of hello assert: that: @@ -177,7 +168,7 @@ - name: verify sane error message assert: that: - - "'E:Failed to fetch' in apt_result['msg']" + - "'Failed to fetch' in apt_result['msg']" - "'403' in apt_result['msg']" - name: Clean up diff --git a/test/integration/targets/apt/tasks/main.yml b/test/integration/targets/apt/tasks/main.yml index 4cb63a39ce..9082f63dd1 100644 --- a/test/integration/targets/apt/tasks/main.yml +++ b/test/integration/targets/apt/tasks/main.yml @@ -15,69 +15,63 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . - - include: 'apt.yml' - when: ansible_distribution in ('Ubuntu', 'Debian') +- block: + - include: 'apt.yml' - - block: - - include: 'repo.yml' - always: - - apt_repository: - repo: "deb file:{{ repodir }} ./" - state: absent - - file: - name: "{{ repodir }}" - state: absent - when: ansible_distribution in ('Ubuntu', 'Debian') + - block: + - include: 'repo.yml' + always: + - apt_repository: + repo: "deb file:{{ repodir }} ./" + state: absent + - file: + name: "{{ repodir }}" + state: absent - - include: 'apt-multiarch.yml' - when: ansible_distribution in ('Ubuntu', 'Debian') and ansible_userspace_architecture != apt_foreign_arch + - include: 'apt-multiarch.yml' + when: + - ansible_userspace_architecture != apt_foreign_arch - - include: 'apt-builddep.yml' - when: ansible_distribution in ('Ubuntu', 'Debian') + - include: 'apt-builddep.yml' - - include: upgrade.yml upgrade_type=dist - when: ansible_distribution in ('Ubuntu', 'Debian') + - 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 - when: ansible_distribution in ('Ubuntu', 'Debian') + - name: Check if aptitude is installed + command: dpkg-query --show --showformat='${db:Status-Abbrev}' aptitude + register: aptitude_status - - debug: var=aptitude_status.stdout + - name: Remove aptitude, if installed, to test fall-back to apt-get + apt: + pkg: aptitude + state: absent + when: + - aptitude_status.stdout.find('ii') != -1 - - 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 } - - include: "upgrade.yml aptitude_present={{ False | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}" - when: - - ansible_distribution in ('Ubuntu', 'Debian') - 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 - - 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 } - - include: upgrade.yml upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }} - when: - - ansible_distribution in ('Ubuntu', 'Debian') - 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 - - name: Remove aptitude if not originally present - apt: - pkg: aptitude - state: absent - when: - - aptitude_status.stdout.find('ii') == -1 + when: + - ansible_distribution in ('Ubuntu', 'Debian') diff --git a/test/integration/targets/apt/tasks/upgrade.yml b/test/integration/targets/apt/tasks/upgrade.yml index 1fec0cc79d..c9ab62f230 100644 --- a/test/integration/targets/apt/tasks/upgrade.yml +++ b/test/integration/targets/apt/tasks/upgrade.yml @@ -7,41 +7,35 @@ shell: dpkg -s hello | grep Version | awk '{print $2}' register: hello_version -- debug: var=hello_version - - name: ensure the correct version of hello has been installed assert: that: - "{{ hello_version.stdout }}=={{ hello_old_version }}" -- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version, force_apt_get: {{force_apt_get|default(False)}}" +- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version, force_apt_get: {{force_apt_get}}" apt: upgrade: "{{ upgrade_type }}" - force_apt_get: "{{ force_apt_get | default(False) }}" + force_apt_get: "{{ force_apt_get }}" register: upgrade_result - name: check hello version shell: dpkg -s hello | grep Version | awk '{print $2}' register: hello_version -- debug: var=upgrade_result.warnings|default([]) -- debug: var=aptitude_present -- debug: var=force_apt_get - - name: check that warning is not given when force_apt_get set assert: that: - - "'Could not find aptitude. Using apt-get instead' not in upgrade_result.warnings | default([])" + - "'warnings' not in upgrade_result" when: - - force_apt_get | default(False) + - force_apt_get - name: check that warning is given when aptitude not found and force_apt_get not set assert: that: - - "'Could not find aptitude. Using apt-get instead' in upgrade_result.warnings" + - "'Could not find aptitude. Using apt-get instead' in upgrade_result.warnings[0]" when: - - not aptitude_present|default(True) - - not force_apt_get|default(False) + - not aptitude_present + - not force_apt_get - name: check that old version upgraded correctly assert: @@ -52,7 +46,7 @@ - name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version (Idempotant)" apt: upgrade: "{{ upgrade_type }}" - force_apt_get: "{{ force_apt_get | default(False) }}" + force_apt_get: "{{ force_apt_get }}" register: second_upgrade_result - name: check that nothing has changed (Idempotant)