|
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 |
3 | 3 |
|
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: |
5 | 7 | proxy_basic_user: ''
|
6 | 8 | proxy_basic_password: ''
|
7 | 9 |
|
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: |
10 | 14 | 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