Skip to content

should rhsm_repository realy fail when trying to disable an inexistent repo? #11426

@StCyr

Description

@StCyr

Summary

rhsm_repostiroy fails when I do:

- name: Disable repository on Red Hat server 
  community.general.rhsm_repository:
    name:
      - "stupid_and_inexistent_dummy_repo_blablabal_randomdfkjsdvoicxjvfdsfsdfp"
    state: disabled
  become: true

Is it really a good idea?

I mean: if I want to disable a repo on a server, isn't it good enough if rhsm_repository doesn't find it?

sidenote: though deprecated, state can still be "absent", in which case I definitively would classify this failure as a bug.

Issue Type

Bug Report

Component Name

rhsm_repository

Ansible Version

$ ansible --version
ansible [core 2.16.14]
  python version = 3.12.11 (main, Aug 15 2025, 13:38:57) [GCC 8.5.0 20210514 (Red Hat 8.5.0-28)]
  jinja version = 3.1.6
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 7.5.9

related code is still in master though:

    for repoid in matched_existing_repo:
        if len(matched_existing_repo[repoid]) == 0:
            results.append(f"{repoid} is not a valid repository ID")
            module.fail_json(results=results, msg=f"{repoid} is not a valid repository ID")

Configuration

$ ansible-config dump --only-changed
sorry sensitive information

OS / Environment

Red Hat Enterprise Linux release 8.10 (Ootpa)

Steps to Reproduce

- name: Disable repository on Red Hat server 
  community.general.rhsm_repository:
    name:
      - "stupid_and_inexistent_dummy_repo_blablabal_randomdfkjsdvoicxjvfdsfsdfp"
    state: disabled
  become: true

Expected Results

community.general.rhsm_repository should not fail when it doesn't find a repo and state is "disabled" or "absent"

Actual Results

output: 
msg: 
stupid_and_inexistent_dummy_repo_blablabal_randomdfkjsdvoicxjvfdsfsdfp is not a valid repository ID

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugmodulemodulepluginsplugin (any type)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions