Check CentOS-Base.repo exists for CentOS 7 (#11546)

Signed-off-by: tu1h <lihai.tu@daocloud.io>
Co-authored-by: tu1h <lihai.tu@daocloud.io>
This commit is contained in:
k8s-infra-cherrypick-robot
2024-09-17 18:40:43 -07:00
committed by GitHub
parent 80201c527f
commit 0b64ab15b5

View File

@@ -88,24 +88,31 @@
- (ansible_distribution_version | float) < 9 - (ansible_distribution_version | float) < 9
# CentOS 7 EOL at July 1, 2024. # CentOS 7 EOL at July 1, 2024.
- name: Disable CentOS 7 mirrorlist in CentOS-Base.repo - name: Check CentOS-Base.repo exists for CentOS 7
replace: stat:
path: /etc/yum.repos.d/CentOS-Base.repo path: /etc/yum.repos.d/CentOS-Base.repo
regexp: '^mirrorlist=' register: centos_base_repo_stat
replace: '#mirrorlist='
become: true
when: when:
- ansible_distribution_major_version == "7" - ansible_distribution_major_version == "7"
# CentOS 7 EOL at July 1, 2024. # CentOS 7 EOL at July 1, 2024.
- name: Update CentOS 7 baseurl in CentOS-Base.repo - name: Update CentOS 7 CentOS-Base.repo
replace:
path: /etc/yum.repos.d/CentOS-Base.repo
regexp: '^#baseurl=http:\/\/mirror.centos.org'
replace: 'baseurl=http:\/\/vault.centos.org'
become: true
when: when:
- ansible_distribution_major_version == "7" - ansible_distribution_major_version == "7"
- centos_base_repo_stat.stat.exists
become: true
block:
- name: Disable CentOS 7 mirrorlist in CentOS-Base.repo
replace:
path: "{{ centos_base_repo_stat.stat.path }}"
regexp: '^mirrorlist='
replace: '#mirrorlist='
- name: Update CentOS 7 baseurl in CentOS-Base.repo
replace:
path: "{{ centos_base_repo_stat.stat.path }}"
regexp: '^#baseurl=http:\/\/mirror.centos.org'
replace: 'baseurl=http:\/\/vault.centos.org'
# CentOS ships with python installed # CentOS ships with python installed