How to disable all repositories using yum module in ansible?
12,136
The Ansible documentation suggests you must supply a comma-separated list of repo ids.
disablerepo: Repoid of repositories to disable for the install/update operation. These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",". As of Ansible 2.7, this can alternatively be a list instead of "," separated string
The example from the documentation:
- name: Install package with multiple repos disabled
yum:
name: sos
disablerepo: "epel,ol7_latest"
You might look into using the yum_repository module as an alternative as well:
# Example removing a repository and cleaning up metadata cache
- name: Remove repository (and clean up left-over metadata)
yum_repository:
name: epel
state: absent
notify: yum-clean-metadata
Author by
JPNagarajan
Updated on June 26, 2022Comments
-
JPNagarajan almost 2 years
I'm trying to disable all the yum repos and enable just 1 repo for installing a yum package.How to disable all repos using yum module?
Tried to use disablerepo='*' but not sure whether this is the correct method
- name: Update the uek kernel pkg on gateways yum: name: "{{ packages }}" disablerepo: "*" enablerepo: test_iso vars: packages: - kernel-uek become_user: root
-
error404 about 5 yearswhat was the outcome of the trial? Any error ?
-
JPNagarajan about 5 yearsDidn't got any error.But just want to know whether this is correct way to disable all repos?
-
error404 about 5 yearsOhk..the list way was easily there in ansible docs to refer. But your question was to delete all the repos using wild card which is not supported may be you can apply some logic and generate the list dynamically and pass it the yum module
-