Skip to content

Commit 3af4552

Browse files
committed
add missing common proxy vars
1 parent f17e331 commit 3af4552

File tree

1 file changed

+21
-12
lines changed
  • environments/common/inventory/group_vars/all

1 file changed

+21
-12
lines changed
Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
# default proxy address to hostname of first squid host, port 3128
2-
# if squid group non-empty, else else empty string to avoid breaking hostvars
1+
# If squid group is non-empty, default the proxy address to the hostname of
2+
# the first squid host, port 3128. Else empty string to avoid breaking hostvars
33

4-
# override these to provide basic_auth:
4+
# Any of these defaults may be overriden in e.g. environments/site/group_vars/all/proxy.yml if required.
5+
6+
# override if basic_auth is required:
57
proxy_basic_user: ''
68
proxy_basic_password: ''
79

8-
# some indirection to make this logic easier:
9-
proxy_http_address: "{{ hostvars[groups['squid'].0].api_address }}"
10+
# hostname/address of proxy - override if not using appliance squid group/role:
11+
proxy_http_address: "{{ (hostvars[groups['squid'].0 | default(None)] | default({})).api_address | default('') }}"
12+
13+
# port of proxy - override if not using appliance squid group/role:
1014
proxy_http_port: "{{ squid_http_port }}"
11-
proxy_basic_auth: "{{ proxy_basic_user }}:{{ proxy_basic_password }}@"
12-
proxy_http_proxy_default: >-
13-
{{ 'http://' +
14-
(proxy_basic_auth if proxy_basic_password != '' else '') +
15-
proxy_http_address + ':' + (proxy_http_port | string)
16-
}}
17-
proxy_http_proxy: "{{ proxy_http_proxy_default if groups['squid'] else '' }}"
15+
16+
# full http proxy string - override if the above don't provide enough control:
17+
proxy_http_proxy: >-
18+
{% if groups['squid'] | length > 0 %}
19+
http://
20+
{%- if proxy_basic_password -%}
21+
{{ proxy_basic_user }}:{{ proxy_basic_password }}@
22+
{%- endif -%}
23+
{{ proxy_http_address }}:{{ proxy_http_port }}
24+
{% else %}
25+
26+
{% endif %}

0 commit comments

Comments
 (0)