diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2024-07-25 17:01:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-25 17:01:46 +0200 |
commit | 504f5b12309d7f07ea2367b7d0445f3e9bfac28f (patch) | |
tree | f2335c14fb7f4d74b13868026d0eb5af49eb9a2c /test | |
parent | increase timeout downloading galaxy role URLs (#83562) (diff) | |
download | ansible-504f5b12309d7f07ea2367b7d0445f3e9bfac28f.tar.xz ansible-504f5b12309d7f07ea2367b7d0445f3e9bfac28f.zip |
apt: Report change when package is removed (#83547)
While upgrade process removes a package, module should
report changed=True instead of changed=False
Fixes: #46314
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/targets/apt/tasks/repo.yml | 3 | ||||
-rw-r--r-- | test/integration/targets/apt/tasks/upgrade_autoremove.yml | 76 |
2 files changed, 79 insertions, 0 deletions
diff --git a/test/integration/targets/apt/tasks/repo.yml b/test/integration/targets/apt/tasks/repo.yml index b1d08afa34..70e2e6a286 100644 --- a/test/integration/targets/apt/tasks/repo.yml +++ b/test/integration/targets/apt/tasks/repo.yml @@ -384,6 +384,8 @@ - { upgrade_type: safe, force_apt_get: True } - { upgrade_type: full, force_apt_get: True } + - include_tasks: "upgrade_autoremove.yml" + - name: (Re-)Install aptitude, run same tests again apt: pkg: aptitude @@ -401,6 +403,7 @@ - { upgrade_type: full, force_apt_get: True } - include_tasks: "upgrade_scenarios.yml" + - include_tasks: "upgrade_autoremove.yml" - name: Remove aptitude if not originally present apt: diff --git a/test/integration/targets/apt/tasks/upgrade_autoremove.yml b/test/integration/targets/apt/tasks/upgrade_autoremove.yml new file mode 100644 index 0000000000..96e3980a3b --- /dev/null +++ b/test/integration/targets/apt/tasks/upgrade_autoremove.yml @@ -0,0 +1,76 @@ +# https://github.com/ansible/ansible/issues/46314 +- block: + - name: Remove upgrades from the equation + apt: + upgrade: true + state: present + update_cache: true + + - name: Install foobar, installs foo as a dependency + apt: + name: foobar=1.0.0 + allow_unauthenticated: true + + - name: Check foobar version + shell: dpkg -s foobar | grep Version | awk '{print $2}' + register: foobar_version + + - name: Ensure the correct version of foobar has been installed + assert: + that: + - "'1.0.0' in foobar_version.stdout" + + - name: Remove foobar, leaving behind its dependency foo + apt: + name: foobar=1.0.0 + state: absent + + - name: Test autoremove + upgrade (check mode) + apt: + autoremove: true + upgrade: true + diff: true + check_mode: true + register: autoremove_check_mode + + - name: Test autoremove + upgrade + apt: + autoremove: true + upgrade: true + diff: true + register: autoremove + + - name: Check that something is changed + assert: + that: + - autoremove.changed + - autoremove_check_mode.changed + + - name: Check foo version + shell: dpkg -s foo | grep Version | awk '{print $2}' + register: foo_version + + - name: Check that old version removed correctly + assert: + that: + - "'1.0.1' not in foo_version.stdout" + - "{{ foo_version.changed }}" + + - name: Test autoremove + upgrade (Idempotant) + apt: + autoremove: true + upgrade: true + diff: true + register: second_upgrade_result + + - name: Check that nothing has changed (Idempotant) + assert: + that: + - "second_upgrade_result.changed == false" + + always: + - name: Clean up + apt: + pkg: foo,foobar + state: absent + autoclean: true |