Skip to content

Commit 49ea0f6

Browse files
committed
add indirection to allow providing basic auth to proxy
1 parent 7d6467d commit 49ea0f6

File tree

1 file changed

+17
-2
lines changed
  • environments/common/inventory/group_vars/all

1 file changed

+17
-2
lines changed
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
# default proxy address to first squid api address port 3128 if squid group non-empty, else empty string to avoid breaking hostvars
2-
proxy_http_proxy: "{{ 'http://' + hostvars[groups['squid'].0].api_address + ':' + (squid_http_port | string) if groups['squid'] else '' }}"
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
3+
4+
# override these to provide basic_auth:
5+
proxy_basic_user: ''
6+
proxy_basic_password: ''
7+
8+
# some indirection to make this logic easier:
9+
proxy_http_address: "{{ hostvars[groups['squid'].0].api_address }}"
10+
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 '' }}"

0 commit comments

Comments
 (0)