Created
July 2, 2024 01:36
-
-
Save ptierno/1955779c7b2ba16d671175305bf1196a to your computer and use it in GitHub Desktop.
Update CentOS repos to use legacy repo URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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