pyinfra icon indicating copy to clipboard operation
pyinfra copied to clipboard

fact YumRepositories should include the repo filename

Open disser opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe

The pattern of inspecting repositories and removing some is not possible because the .repo filename is not provided by the YumRepositories fact, but yum.repo(..., present=False) requires the filename of the repo.

Describe the solution you'd like

YumRepositories should return output including the filename:

[
    {
        "name": "CentOS-$releasever - Apps",
        "baseurl": "http://mirror.centos.org/$contentdir/$releasever/Apps/$basearch/os/",
        "gpgcheck": "1",
        "enabled": "1",
        "gpgkey": "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial",
        "filename": "/etc/yum.repos.d/centos.repo"
    },
]

I'm not sure if the full path should be included, since yum.repo doesn't expect it.

EDIT: oh... I see now how this would be impossible given the current implementation of YumRepositories

disser avatar Nov 26 '23 23:11 disser

Potential solution using tail instead of cat: https://stackoverflow.com/a/7816490

Would be nice to have in there for sure, but non-essential. If added the yum.repo operation could end up duplicating repos in multiple files, or it would need to error if the repo was found somewhere unexpected (or remove it, could get messy).

Fizzadar avatar Nov 29 '23 16:11 Fizzadar