Skip to content

Commit 0b64ab1

Browse files
Check CentOS-Base.repo exists for CentOS 7 (#11546)
Signed-off-by: tu1h <[email protected]> Co-authored-by: tu1h <[email protected]>
1 parent 80201c5 commit 0b64ab1

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

roles/bootstrap-os/tasks/bootstrap-centos.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,31 @@
8888
- (ansible_distribution_version | float) < 9
8989

9090
# CentOS 7 EOL at July 1, 2024.
91-
- name: Disable CentOS 7 mirrorlist in CentOS-Base.repo
92-
replace:
91+
- name: Check CentOS-Base.repo exists for CentOS 7
92+
stat:
9393
path: /etc/yum.repos.d/CentOS-Base.repo
94-
regexp: '^mirrorlist='
95-
replace: '#mirrorlist='
96-
become: true
94+
register: centos_base_repo_stat
9795
when:
9896
- ansible_distribution_major_version == "7"
9997

10098
# CentOS 7 EOL at July 1, 2024.
101-
- name: Update CentOS 7 baseurl in CentOS-Base.repo
102-
replace:
103-
path: /etc/yum.repos.d/CentOS-Base.repo
104-
regexp: '^#baseurl=http:\/\/mirror.centos.org'
105-
replace: 'baseurl=http:\/\/vault.centos.org'
106-
become: true
99+
- name: Update CentOS 7 CentOS-Base.repo
107100
when:
108101
- ansible_distribution_major_version == "7"
102+
- centos_base_repo_stat.stat.exists
103+
become: true
104+
block:
105+
- name: Disable CentOS 7 mirrorlist in CentOS-Base.repo
106+
replace:
107+
path: "{{ centos_base_repo_stat.stat.path }}"
108+
regexp: '^mirrorlist='
109+
replace: '#mirrorlist='
110+
111+
- name: Update CentOS 7 baseurl in CentOS-Base.repo
112+
replace:
113+
path: "{{ centos_base_repo_stat.stat.path }}"
114+
regexp: '^#baseurl=http:\/\/mirror.centos.org'
115+
replace: 'baseurl=http:\/\/vault.centos.org'
109116

110117
# CentOS ships with python installed
111118

0 commit comments

Comments
 (0)