diff --git a/ansible/roles/pip/tasks/pip_conf.yml b/ansible/roles/pip/tasks/pip_conf.yml
index 2fef94f69..a9261e0b3 100644
--- a/ansible/roles/pip/tasks/pip_conf.yml
+++ b/ansible/roles/pip/tasks/pip_conf.yml
@@ -10,7 +10,9 @@
   copy:
     content: |
       [global]
+      {% if pip_index_url | length > 0 -%}
       index-url = {{ pip_index_url }}
+      {% endif -%}
       {% if pip_trusted_hosts | length > 0 -%}
       trusted-host =
         {% for host in pip_trusted_hosts | unique -%}
@@ -30,5 +32,6 @@
       [easy_install]
       index-url = {{ pip_index_url }}
     dest: "~{{ user}}/.pydistutils.cfg"
+  when: pip_index_url | length > 0
   become: True
   become_user: "{{ user }}"
diff --git a/releasenotes/notes/pip-index-url-conditional-3f9c5b3c5c808500.yaml b/releasenotes/notes/pip-index-url-conditional-3f9c5b3c5c808500.yaml
new file mode 100644
index 000000000..b995bd9d7
--- /dev/null
+++ b/releasenotes/notes/pip-index-url-conditional-3f9c5b3c5c808500.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+  - |
+    Fixes generation of pip configuration when using a pip proxy without
+    a local mirror.