Skip to content

Instantly share code, notes, and snippets.

@ptierno
Created July 2, 2024 01:36
Show Gist options
  • Save ptierno/1955779c7b2ba16d671175305bf1196a to your computer and use it in GitHub Desktop.
Save ptierno/1955779c7b2ba16d671175305bf1196a to your computer and use it in GitHub Desktop.
Update CentOS repos to use legacy repo URL
- name: Find all .repo files in /etc/yum.repos.d/
ansible.builtin.find:
paths: "/etc/yum.repos.d/"
patterns: "*.repo"
register: repo_files
- name: Update .repo files to use CentOS Vault for baseurl
ansible.builtin.replace:
path: "{{ item.path }}"
regexp: '^#?(?:\s+)?baseurl=.*mirror.centos.org(.*)'
replace: 'baseurl=http://vault.centos.org\1'
backup: yes
loop: "{{ repo_files.files }}"
- name: Remove mirrorlist entries in .repo files
ansible.builtin.replace:
path: "{{ item.path }}"
regexp: '^(mirrorlist=http://mirrorlist.centos.org.*$)'
replace: '#\1'
backup: yes
loop: "{{ repo_files.files }}"
- name: clean yum cache
shell: yum clean all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment