From ab3a7280325a90ef254a1fa0b2807a28b562faeb Mon Sep 17 00:00:00 2001 From: Ashley Nelson Date: Fri, 24 Jan 2020 13:58:08 -0600 Subject: [PATCH] Add custom venv support for proxies --- .../kubernetes/templates/deployment.yml.j2 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/installer/roles/kubernetes/templates/deployment.yml.j2 b/installer/roles/kubernetes/templates/deployment.yml.j2 index 5941ff6967..28d56d18ca 100644 --- a/installer/roles/kubernetes/templates/deployment.yml.j2 +++ b/installer/roles/kubernetes/templates/deployment.yml.j2 @@ -154,9 +154,22 @@ spec: serviceAccountName: awx terminationGracePeriodSeconds: 10 {% if custom_venvs is defined %} +{% set trusted_hosts = "" %} initContainers: - image: 'centos:7' name: init-custom-venvs +{% if http_proxy is defined or https_proxy is defined %} +{% set trusted_hosts = "--trusted-host pypi.org --trusted-host files.pythonhosted.org --trusted-host pypi.python.org" %} + env: +{% if http_proxy is defined %} + - name: http_proxy + value: {{ http_proxy }} +{% endif %} +{% if https_proxy is defined %} + - name: https_proxy + value: {{ https_proxy }} +{% endif %} +{% endif %} command: - sh - '-c' @@ -169,10 +182,10 @@ spec: virtualenv -p {{ custom_venv.python | default(custom_venvs_python) }} \ {{ custom_venvs_path }}/{{ custom_venv.name }} && source {{ custom_venvs_path }}/{{ custom_venv.name }}/bin/activate && - {{ custom_venvs_path }}/{{ custom_venv.name }}/bin/pip install -U psutil \ + {{ custom_venvs_path }}/{{ custom_venv.name }}/bin/pip install {{ trusted_hosts }} -U psutil \ "ansible=={{ custom_venv.python_ansible_version }}" && {% if custom_venv.python_modules is defined %} - {{ custom_venvs_path }}/{{ custom_venv.name }}/bin/pip install -U \ + {{ custom_venvs_path }}/{{ custom_venv.name }}/bin/pip install {{ trusted_hosts }} -U \ {% for module in custom_venv.python_modules %}{{ module }} {% endfor %} && {% endif %} deactivate &&