diff --git a/roles/bootstrap-os/tasks/bootstrap-centos.yml b/roles/bootstrap-os/tasks/bootstrap-centos.yml
index 4bfe984fdb03291df5ff98dafe9f6ac7924c6747..5429cf62ca907b64caab61d4492536c583e6bf1a 100644
--- a/roles/bootstrap-os/tasks/bootstrap-centos.yml
+++ b/roles/bootstrap-os/tasks/bootstrap-centos.yml
@@ -42,15 +42,14 @@
     - not centos_fastestmirror_enabled
 
 - name: Add proxy to /etc/yum.conf if http_proxy is defined
-  lineinfile:
+  ini_file:
     path: "/etc/yum.conf"
-    regexp: "^proxy=.*$"
-    line: "proxy={{ http_proxy }}"
-    create: true
-    state: present
+    section: main
+    option: proxy
+    value: "{{ http_proxy | default(omit) }}"
+    state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
+    no_extra_spaces: true
   become: true
-  when:
-    - http_proxy is defined
 
 - name: Gather host facts to get ansible_distribution_major_version
   setup:
diff --git a/roles/container-engine/docker/tasks/main.yml b/roles/container-engine/docker/tasks/main.yml
index 85d50e5763c3ee8450da74550e9c14dfd7b74419..836c2b8f8beec03878c5f2ae060be3b9e967c065 100644
--- a/roles/container-engine/docker/tasks/main.yml
+++ b/roles/container-engine/docker/tasks/main.yml
@@ -136,11 +136,12 @@
   when: ansible_distribution in ["CentOS","RedHat","OracleLinux"] and not is_ostree
 
 - name: Edit copy of yum.conf to set obsoletes=0
-  lineinfile:
+  ini_file:
     path: "{{ docker_yum_conf }}"
-    state: present
-    regexp: '^obsoletes='
-    line: 'obsoletes=0'
+    section: main
+    option: obsoletes
+    value: "0"
+    no_extra_spaces: true
   when: ansible_distribution in ["CentOS","RedHat","OracleLinux"] and not is_ostree
 
 - name: ensure docker packages are installed
diff --git a/roles/container-engine/docker/templates/rh_docker.repo.j2 b/roles/container-engine/docker/templates/rh_docker.repo.j2
index 81f9c37d5a639880052dcac137e5defdae900e2f..fe01ed2e6d4c51c18fdcbdb65d4443450899073c 100644
--- a/roles/container-engine/docker/templates/rh_docker.repo.j2
+++ b/roles/container-engine/docker/templates/rh_docker.repo.j2
@@ -6,4 +6,5 @@ gpgcheck={{ '1' if docker_rh_repo_gpgkey else '0' }}
 keepcache={{ docker_rpm_keepcache | default('1') }}
 gpgkey={{ docker_rh_repo_gpgkey }}
 {% if http_proxy is defined %}proxy={{ http_proxy }}{% endif %}
+
 {% if ansible_os_family == "RedHat" and ansible_distribution_major_version|int == 8 %}module_hotfixes=True{% endif %}