How to alter configuration for specific yum repository

Alter configuration for specific yum repository.

Operating system.

$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)

Inspect repository options.

$ yum-config-manager google-cloud-compute                                                
Loaded plugins: fastestmirror
======================================== repo: google-cloud-compute =========================================
[google-cloud-compute]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = https://packages.cloud.google.com/yum/repos/google-cloud-compute-el7-x86_64
cache = 0
cachedir = /var/cache/yum/x86_64/7/google-cloud-compute
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage = 
enabled = True
enablegroups = True
exclude = 
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/google-cloud-compute/gpgcadir
gpgcakey = 
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/google-cloud-compute/gpgdir
gpgkey = https://packages.cloud.google.com/yum/doc/yum-key.gpg,
   https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
hdrdir = /var/cache/yum/x86_64/7/google-cloud-compute/headers
http_caching = all
includepkgs = 
ip_resolve = ipv4
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid = 
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink = 
minrate = 0
mirrorlist = 
mirrorlist_expire = 86400
name = Google Cloud Compute
old_base_cache_dir = 
password = 
persistdir = /var/lib/yum/repos/x86_64/7/google-cloud-compute
pkgdir = /var/cache/yum/x86_64/7/google-cloud-compute/packages
proxy = False
proxy_dict = 
proxy_password = 
proxy_username = 
repo_gpgcheck = True
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = True
throttle = 0
timeout = 30.0
ui_id = google-cloud-compute
ui_repoid_vars = releasever,
   basearch
username =

This corresponds to the repository configuration file.

$ cat /etc/yum.repos.d/google-cloud.repo 
[google-cloud-compute]
name=Google Cloud Compute
baseurl=https://packages.cloud.google.com/yum/repos/google-cloud-compute-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
         https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
ip_resolve = ipv4
keepcache = 0
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
         https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
ip_resolve = ipv4
keepcache = 0

Increase connection timeout for every repository definition matching google-cloud-*.

$ sudo yum-config-manager --setopt=google-cloud-\*.timeout=60 --save

Ensure that yum will continue when google-cloud-compute repository cannot be contacted.

$ sudo yum-config-manager --setopt=google-cloud-compute.skip_if_unavailable=True --save

Inspect altered repository options.

$ yum-config-manager google-cloud-compute                                                
Loaded plugins: fastestmirror
======================================== repo: google-cloud-compute =========================================
[google-cloud-compute]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = https://packages.cloud.google.com/yum/repos/google-cloud-compute-el7-x86_64
cache = 0
cachedir = /var/cache/yum/x86_64/7/google-cloud-compute
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage = 
enabled = True
enablegroups = True
exclude = 
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/google-cloud-compute/gpgcadir
gpgcakey = 
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/google-cloud-compute/gpgdir
gpgkey = https://packages.cloud.google.com/yum/doc/yum-key.gpg,
   https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
hdrdir = /var/cache/yum/x86_64/7/google-cloud-compute/headers
http_caching = all
includepkgs = 
ip_resolve = ipv4
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid = 
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink = 
minrate = 0
mirrorlist = 
mirrorlist_expire = 86400
name = Google Cloud Compute
old_base_cache_dir = 
password = 
persistdir = /var/lib/yum/repos/x86_64/7/google-cloud-compute
pkgdir = /var/cache/yum/x86_64/7/google-cloud-compute/packages
proxy = False
proxy_dict = 
proxy_password = 
proxy_username = 
repo_gpgcheck = True
retries = 10
skip_if_unavailable = True
ssl_check_cert_permissions = True
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = True
throttle = 0
timeout = 60.0
ui_id = google-cloud-compute
ui_repoid_vars = releasever,
   basearch
username =

This will correspond to single or multiple configuration files for given repositories.

$ cat /etc/yum.repos.d/google-cloud.repo
[google-cloud-compute]
name=Google Cloud Compute
baseurl=https://packages.cloud.google.com/yum/repos/google-cloud-compute-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
                  https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
ip_resolve = ipv4
keepcache = 0
timeout = 60.0
skip_if_unavailable = 1
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
              https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
ip_resolve = ipv4
keepcache = 0
timeout = 60.0