Skip to content

Commit 31bfef5

Browse files
committed
Updates for proxy_env variable (for offline installation)
* 'environment' parameter cannot be properly omitted with 'omit' variable ansible/ansible#46533 ansible/ansible#14130 "Default (omit)" is replaced by "default ({})" for proxy_env. This is necessary to avoid a warning: [WARNING]: could not parse environment value, skipping: [u '{{proxy_env | default (omit)}} '] * The proxy_env variable has been moved to the beginning of the /vars/main.yml file. * A small update to README.md file with an example of using proxy_env.
1 parent 9648be6 commit 31bfef5

12 files changed

+29
-19
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,22 @@ Ansible ([What is Ansible](https://www.ansible.com/resources/videos/quick-start-
108108

109109
4. Edit the variable file vars/[main.yml](./vars/main.yml)
110110

111+
`vim vars/main.yml`
112+
111113
###### Minimum set of variables:
114+
- `proxy_env` (for offline installation)
115+
116+
example:
117+
```
118+
proxy_env:
119+
http_proxy: http://proxy_server_ip:port
120+
https_proxy: http://proxy_server_ip:port
121+
```
112122
- `cluster_vip`
113123
- `patroni_cluster_name`
114124
- `with_haproxy_load_balancing` `'true'` (Type A) or `'false'`/default (Type B)
115125
- `postgresql_version`
116-
- `proxy_env` (if required)
117126

118-
`vim vars/main.yml`
119127

120128
5. Run playbook:
121129

tasks/add-repository.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
state: present
1515
update_cache: yes
1616
loop: "{{ apt_repository }}"
17-
environment: "{{ proxy_env | default(omit) }}"
17+
environment: '{{ proxy_env | default({}) }}'
1818
when: ansible_os_family == "Debian"
1919
tags: add_repo
2020

@@ -62,6 +62,6 @@
6262
state: present
6363
when: install_postgresql_repo == "true"
6464
tags: install_postgresql_repo
65-
environment: "{{ proxy_env | default(omit) }}"
65+
environment: '{{ proxy_env | default({}) }}'
6666
when: ansible_os_family == "RedHat"
6767
tags: add_repo

tasks/confd.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
mode: u+x,g+x,o+x
88
timeout: 30
99
validate_certs: no
10-
environment: "{{ proxy_env | default(omit) }}"
10+
environment: '{{ proxy_env | default({}) }}'
1111
tags: [ get_confd, confd ]
1212

1313
- name: confd | create conf directories

tasks/etcd.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
dest: /tmp/
77
remote_src: yes
88
validate_certs: no
9-
environment: "{{ proxy_env | default(omit) }}"
9+
environment: '{{ proxy_env | default({}) }}'
1010

1111
- name: etcd cluster | copy "etcd" and "etcdctl" binary files to /usr/local/bin/
1212
copy:

tasks/haproxy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
- openssl-libs
5656
- systemd-devel
5757
when: ansible_os_family == "RedHat"
58-
environment: "{{ proxy_env | default(omit) }}"
58+
environment: '{{ proxy_env | default({}) }}'
5959

6060
- name: haproxy | add haproxy group
6161
group:

tasks/keepalived.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- name: keepalived | install packages
44
package:
55
name: keepalived
6-
environment: "{{ proxy_env | default(omit) }}"
6+
environment: '{{ proxy_env | default({}) }}'
77
tags: [ keepalived_install, keepalived ]
88

99
- name: keepalived | make sure the kernel parameters "net.ipv4.ip_nonlocal_bind", "net.ipv4.ip_forward" are enabled

tasks/ntp.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- name: ntp | install package
44
package:
55
name: ntp
6-
environment: "{{ proxy_env | default(omit) }}"
6+
environment: '{{ proxy_env | default({}) }}'
77
tags: [ ntp_install, ntp ]
88

99
- name: ntp | copy the ntp.conf template file

tasks/packages.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package:
66
name: "{{ item }}"
77
loop: "{{ system_packages }}"
8-
environment: "{{ proxy_env | default(omit) }}"
8+
environment: '{{ proxy_env | default({}) }}'
99
tags: install_packages
1010

1111
# PostgreSQL prepare for install (for Debian based only)
@@ -14,7 +14,7 @@
1414
package:
1515
name: postgresql-common
1616
state: present
17-
environment: "{{ proxy_env | default(omit) }}"
17+
environment: '{{ proxy_env | default({}) }}'
1818

1919
- name: disable initializing of a default postgresql cluster
2020
replace:
@@ -34,6 +34,6 @@
3434
package:
3535
name: "{{ item }}"
3636
loop: "{{ postgresql_packages }}"
37-
environment: "{{ proxy_env | default(omit) }}"
37+
environment: '{{ proxy_env | default({}) }}'
3838
when: postgresql_exists != "true"
3939
tags: install_postgres

tasks/patroni.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
name: urllib3<1.25
4949
executable: /usr/local/bin/pip3
5050
extra_args: "--trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org"
51-
environment: "{{ proxy_env | default(omit) }}"
51+
environment: '{{ proxy_env | default({}) }}'
5252
tags: [ patroni, patroni_install ]
5353

5454
- name: Patroni | create conf directory

tasks/pgbouncer.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- name: PgBouncer | install package
44
package:
55
name: pgbouncer
6-
environment: "{{ proxy_env | default(omit) }}"
6+
environment: '{{ proxy_env | default({}) }}'
77
tags: [ pgbouncer_install, pgbouncer ]
88

99
- name: PgBouncer | ensure config directory "{{ pgbouncer_conf_dir }}" exist

tasks/pip.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
command: python3 get-pip.py --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org
1616
args:
1717
chdir: /tmp/
18-
environment: "{{ proxy_env | default(omit) }}"
18+
environment: '{{ proxy_env | default({}) }}'
1919
tags: [ pip_install, pip ]

vars/main.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
---
2+
# Proxy variables (for offline installation)
3+
proxy_env: {}
4+
# http_proxy: http://10.128.64.9:3128
5+
# https_proxy: http://10.128.64.9:3128
6+
7+
# -------------------------------------------
28

39
# Cluster variables
410
cluster_vip: "10.128.64.145" # for client access to databases in the cluster
@@ -158,10 +164,6 @@ pgbouncer_users:
158164

159165

160166
# System variables
161-
proxy_env: []
162-
# http_proxy: http://10.128.64.9:3128
163-
# https_proxy: http://10.128.64.9:3128
164-
165167
ntp_enabled: 'false' # specify 'true' if you want to install and configure the ntp service
166168
ntp_servers: []
167169
# - "10.128.64.44"

0 commit comments

Comments
 (0)