diff --git a/changelogs/fragments/6676-rhsm_repository-fix-returned-repositories-with-purge.yml b/changelogs/fragments/6676-rhsm_repository-fix-returned-repositories-with-purge.yml new file mode 100644 index 0000000000..ec2dd38575 --- /dev/null +++ b/changelogs/fragments/6676-rhsm_repository-fix-returned-repositories-with-purge.yml @@ -0,0 +1,6 @@ +bugfixes: + - | + rhsm_repository - when using the ``purge`` option, the ``repositories`` + dictionary element in the returned JSON is now properly updated according + to the pruning operation + (https://github.com/ansible-collections/community.general/pull/6676). diff --git a/plugins/modules/rhsm_repository.py b/plugins/modules/rhsm_repository.py index c7f88b03ef..151d0e8810 100644 --- a/plugins/modules/rhsm_repository.py +++ b/plugins/modules/rhsm_repository.py @@ -226,6 +226,9 @@ def repository_modify(module, state, name, purge=False): diff_after.join("Repository '{repoid}' is disabled for this system\n".format(repoid=repoid)) results.append("Repository '{repoid}' is disabled for this system".format(repoid=repoid)) rhsm_arguments.extend(['--disable', repoid]) + for updated_repo in updated_repo_list: + if updated_repo['id'] in difference: + updated_repo['enabled'] = False diff = {'before': diff_before, 'after': diff_after,