diff --git a/roles/eda/tasks/deploy_eda.yml b/roles/eda/tasks/deploy_eda.yml index 144899de..eef89c73 100644 --- a/roles/eda/tasks/deploy_eda.yml +++ b/roles/eda/tasks/deploy_eda.yml @@ -25,6 +25,14 @@ definition: "{{ lookup('template', 'eda.configmap.yaml.j2') }}" wait: yes +- name: Set gateway and controller hostnames for NO_PROXY exclusion + ansible.builtin.set_fact: + _gateway_hostname: >- + {{ extra_settings | default([]) | selectattr('setting', 'equalto', 'EDA_ANSIBLE_BASE_JWT_KEY') + | map(attribute='value') | select | list | first | default('') + | urlsplit('hostname') }} + _controller_hostname: "{{ automation_server_url | default('') | urlsplit('hostname') }}" + - name: Apply proxy environment ConfigMap k8s: apply: yes diff --git a/roles/eda/templates/eda-proxy-env.configmap.yaml.j2 b/roles/eda/templates/eda-proxy-env.configmap.yaml.j2 index 7d2a0045..74c50320 100644 --- a/roles/eda/templates/eda-proxy-env.configmap.yaml.j2 +++ b/roles/eda/templates/eda-proxy-env.configmap.yaml.j2 @@ -13,7 +13,16 @@ data: HTTPS_PROXY: '{{ https_proxy }}' https_proxy: '{{ https_proxy }}' {% endif %} -{% if no_proxy %} - NO_PROXY: '{{ no_proxy }}' - no_proxy: '{{ no_proxy }}' +{% if http_proxy or https_proxy or no_proxy %} +{% set _no_proxy_list = (no_proxy | default('')).split(',') | map('trim') | select | list %} +{% set _required = ['localhost', '127.0.0.1', '::1', '[::1]', '.svc', '.svc.cluster.local', ansible_operator_meta.name, ansible_operator_meta.name + '.' + ansible_operator_meta.namespace, ansible_operator_meta.name + '-api', ansible_operator_meta.name + '-api.' + ansible_operator_meta.namespace, ansible_operator_meta.name + '-daphne', ansible_operator_meta.name + '-daphne.' + ansible_operator_meta.namespace] %} +{% if _gateway_hostname | default('') %} +{% set _required = (_required + [_gateway_hostname, _gateway_hostname + '.' + ansible_operator_meta.namespace]) | unique %} +{% endif %} +{% if _controller_hostname | default('') %} +{% set _required = (_required + [_controller_hostname, _controller_hostname + '.' + ansible_operator_meta.namespace]) | unique %} +{% endif %} +{% set _augmented = (_no_proxy_list + _required) | unique | join(',') %} + NO_PROXY: '{{ _augmented }}' + no_proxy: '{{ _augmented }}' {% endif %}