ansible.builtin.yum_repository – Add or remove YUM repositories
ansible.builtin.yum_repository – Add or remove YUM repositories
Note
This module is part of ansible-base
and included in all Ansible installations. In most cases, you can use the short module name yum_repository even without specifying the collections:
keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.
New in version 2.1: of ansible.builtin
Synopsis
- Add or remove YUM repositories in RPM-based Linux distributions.
- If you wish to update an existing repository definition use community.general.ini_file instead.
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
async boolean |
|
If set to |
attributes string added in 2.3 of ansible.builtin |
The attributes the resulting file or directory should have. To get supported flags look at the man page for chattr on the target system. This string should contain the attributes in the same order as the one displayed by lsattr. The
| |
bandwidth string |
Default: 0 |
Maximum available network bandwidth in bytes/second. Used with the throttle option. If throttle is a percentage and bandwidth is |
baseurl list / elements=string |
URL to the directory where the yum repository's 'repodata' directory lives. It can also be a list of multiple URLs. This, the metalink or mirrorlist parameters are required if state is set to | |
cost string |
Default: 1000 |
Relative cost of accessing this repository. Useful for weighing one repo's packages as greater/less than any other. |
deltarpm_metadata_percentage string |
Default: 100 |
When the relative size of deltarpm metadata vs pkgs is larger than this, deltarpm metadata is not downloaded from the repo. Note that you can give values over |
deltarpm_percentage string |
Default: 75 |
When the relative size of delta vs pkg is larger than this, delta is not used. Use |
description string |
A human readable string describing the repository. This option corresponds to the "name" property in the repo file. This parameter is only required if state is set to | |
enabled boolean |
|
This tells yum whether or not use this repository. Yum default value is |
enablegroups boolean |
|
Determines whether yum will allow the use of package groups for this repository. Yum default value is |
exclude list / elements=string |
List of packages to exclude from updates or installs. This should be a space separated list. Shell globs using wildcards (eg. The list can also be a regular YAML array. | |
failovermethod string |
|
|
file string |
File name without the | |
gpgcakey string |
A URL pointing to the ASCII-armored CA key file for the repository. | |
gpgcheck boolean |
|
Tells yum whether or not it should perform a GPG signature check on packages. No default setting. If the value is not set, the system setting from |
gpgkey list / elements=string |
A URL pointing to the ASCII-armored GPG key file for the repository. It can also be a list of multiple URLs. | |
group string |
Name of the group that should own the file/directory, as would be fed to chown. | |
http_caching string |
|
Determines how upstream HTTP caches are instructed to handle any HTTP downloads that Yum does.
|
include string |
Include external configuration file. Both, local path and URL is supported. Configuration file will be inserted at the position of the include= line. Included files may contain further include lines. Yum will abort with an error if an inclusion loop is detected. | |
includepkgs list / elements=string |
List of packages you want to only use from a repository. This should be a space separated list. Shell globs using wildcards (eg. The list can also be a regular YAML array. | |
ip_resolve string |
|
Determines how yum resolves host names.
|
keepalive boolean |
|
This tells yum whether or not HTTP/1.1 keepalive should be used with this repository. This can improve transfer speeds by using one connection when downloading multiple files from a repository. |
keepcache string |
|
Either |
metadata_expire string |
Default: 21600 |
Time (in seconds) after which the metadata will expire. Default value is 6 hours. |
metadata_expire_filter string |
|
Filter the metadata_expire time, allowing a trade of speed for accuracy if a command doesn't require it. Each yum command can specify that it requires a certain level of timeliness quality from the remote repos. from "I'm about to install/upgrade, so this better be current" to "Anything that's available is good enough".
Note that this option does not override "yum clean expire-cache". |
metalink string |
Specifies a URL to a metalink file for the repomd.xml, a list of mirrors for the entire repository are generated by converting the mirrors for the repomd.xml file to a baseurl. This, the baseurl or mirrorlist parameters are required if state is set to | |
mirrorlist string |
Specifies a URL to a file containing a list of baseurls. This, the baseurl or metalink parameters are required if state is set to | |
mirrorlist_expire string |
Default: 21600 |
Time (in seconds) after which the mirrorlist locally cached will expire. Default value is 6 hours. |
mode raw |
The permissions the resulting file or directory should have. For those used to /usr/bin/chmod remember that modes are actually octal numbers. You must either add a leading zero so that Ansible's YAML parser knows it is an octal number (like Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results. As of Ansible 1.8, the mode may be specified as a symbolic mode (for example, If If Specifying | |
module_hotfixes boolean added in 2.11 of ansible.builtin |
|
Disable module RPM filtering and make all RPMs from the repository available. The default is |
name string / required |
Unique repository ID. This option builds the section name of the repository in the repo file. This parameter is only required if state is set to | |
owner string |
Name of the user that should own the file/directory, as would be fed to chown. | |
password string |
Password to use with the username for basic authentication. | |
priority string |
Default: 99 |
Enforce ordered protection of repositories. The value is an integer from 1 to 99. This option only works if the YUM Priorities plugin is installed. |
protect boolean |
|
Protect packages from updates from other repositories. |
proxy string |
URL to the proxy server that yum should use. Set to | |
proxy_password string |
Password for this proxy. | |
proxy_username string |
Username to use for proxy. | |
repo_gpgcheck boolean |
|
This tells yum whether or not it should perform a GPG signature check on the repodata from this repository. |
reposdir path |
Default: "/etc/yum.repos.d" |
Directory where the |
retries string |
Default: 10 |
Set the number of times any attempt to retrieve a file should retry before returning an error. Setting this to |
s3_enabled boolean |
|
Enables support for S3 repositories. This option only works if the YUM S3 plugin is installed. |
selevel string |
The level part of the SELinux file context. This is the MLS/MCS attribute, sometimes known as the When set to | |
serole string |
The role part of the SELinux file context. When set to | |
setype string |
The type part of the SELinux file context. When set to | |
seuser string |
The user part of the SELinux file context. By default it uses the When set to | |
skip_if_unavailable boolean |
|
If set to |
ssl_check_cert_permissions boolean |
|
Whether yum should check the permissions on the paths for the certificates on the repository (both remote and local). If we can't read any of the files then yum will force skip_if_unavailable to be |
sslcacert string |
Path to the directory containing the databases of the certificate authorities yum should use to verify SSL certificates.
| |
sslclientcert string |
Path to the SSL client certificate yum should use to connect to repos/remote sites.
| |
sslclientkey string |
Path to the SSL client key yum should use to connect to repos/remote sites.
| |
sslverify boolean |
|
Defines whether yum should verify SSL certificates/hosts at all.
|
state string |
|
State of the repo file. |
throttle string |
Enable bandwidth throttling for downloads. This option can be expressed as a absolute data rate in bytes/sec. An SI prefix (k, M or G) may be appended to the bandwidth value. | |
timeout string |
Default: 30 |
Number of seconds to wait for a connection before timing out. |
ui_repoid_vars string |
Default: "releasever basearch" |
When a repository id is displayed, append these yum variables to the string if they are used in the baseurl/etc. Variables are appended in the order listed (and found). |
unsafe_writes boolean added in 2.2 of ansible.builtin |
|
Influence when to use atomic operation to prevent data corruption or inconsistent reads from the target file. By default this module uses atomic operations to prevent data corruption or inconsistent reads from the target files, but sometimes systems are configured or just broken in ways that prevent this. One example is docker mounted files, which cannot be updated atomically from inside the container and can only be written in an unsafe manner. This option allows Ansible to fall back to unsafe methods of updating files when atomic operations fail (however, it doesn't force Ansible to perform unsafe writes). IMPORTANT! Unsafe writes are subject to race conditions and can lead to data corruption. |
username string |
Username to use for basic authentication to a repo or really any url. |
Notes
Note
- All comments will be removed if modifying an existing repo file.
- Section order is preserved in an existing repo file.
- Parameters in a section are ordered alphabetically in an existing repo file.
- The repo file will be automatically deleted if it contains no repository.
- When removing a repository, beware that the metadata cache may still remain on disk until you run
yum clean all
. Use a notification handler for this. - The
params
parameter was removed in Ansible 2.5 due to circumventing Ansible’s parameter handling
Examples
- name: Add repository
yum_repository:
name: epel
description: EPEL YUM repo
baseurl: https://download.fedoraproject.org/pub/epel/$releasever/$basearch/
- name: Add multiple repositories into the same file (1/2)
yum_repository:
name: epel
description: EPEL YUM repo
file: external_repos
baseurl: https://download.fedoraproject.org/pub/epel/$releasever/$basearch/
gpgcheck: no
- name: Add multiple repositories into the same file (2/2)
yum_repository:
name: rpmforge
description: RPMforge YUM repo
file: external_repos
baseurl: http://apt.sw.be/redhat/el7/en/$basearch/rpmforge
mirrorlist: http://mirrorlist.repoforge.org/el7/mirrors-rpmforge
enabled: no
# Handler showing how to clean yum metadata cache
- name: yum-clean-metadata
command: yum clean metadata
args:
warn: no
# 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
- name: Remove repository from a specific repo file
yum_repository:
name: epel
file: external_repos
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
repo string |
success |
repository name
Sample: epel |
state string |
success |
state of the target, after execution
Sample: present |
Authors
- Jiri Tyr (@jtyr)
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/ansible/builtin/yum_repository_module.html