Skip to content

Commit e01f23e

Browse files
committed
pulp_auth_proxy: Support deploying on hosts without Docker bridge networking
We need to tell Docker to use host networking when bridge networking is not enabled.
1 parent 08087a0 commit e01f23e

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

doc/source/contributor/environments/ci-builder.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ Pulp proxy that injects an HTTP basic auth header into requests that it
123123
proxies. Because this proxy bypasses Pulp's authentication, it must not be
124124
exposed to any untrusted environment.
125125

126+
Ensure that ``localhost`` is resolvable if Docker bridge networking is
127+
disabled. This may be achieved by adding the following to ``/etc/hosts``:
128+
129+
.. parsed-literal::
130+
131+
127.0.0.1 localhost
132+
126133
To deploy the proxy:
127134

128135
.. parsed-literal::

etc/kayobe/ansible/roles/pulp_auth_proxy/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ pulp_auth_proxy_password:
55
pulp_auth_proxy_conf_path:
66
pulp_auth_proxy_listen_ip: 127.0.0.1
77
pulp_auth_proxy_listen_port: 80
8+
pulp_auth_proxy_network_mode:

etc/kayobe/ansible/roles/pulp_auth_proxy/tasks/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
---
2+
- when: pulp_auth_proxy_network_mode is none
3+
block:
4+
- name: Check if Docker bridge network exists
5+
community.docker.docker_host_info:
6+
networks: true
7+
register: docker_host_info
8+
9+
- name: Set a fact about the network mode
10+
ansible.builtin.set_fact:
11+
pulp_auth_proxy_network_mode: "{{ 'host' if docker_host_info.networks | selectattr('Driver', 'equalto', 'bridge') | list | length == 0 else 'bridge' }}"
12+
13+
- name: Assert that localhost is resolvable when using host networking
14+
assert:
15+
that:
16+
- "'localhost' is ansible.utils.resolvable"
17+
fail_msg: >-
18+
localhost must be resolvable when using Docker host networking with this container.
19+
Consider adding '127.0.0.1 localhost' to /etc/hosts.
20+
when: pulp_auth_proxy_network_mode == 'host'
21+
222
- name: "Ensure {{ pulp_auth_proxy_conf_path }} exists"
323
ansible.builtin.file:
424
path: "{{ pulp_auth_proxy_conf_path }}"
@@ -18,6 +38,7 @@
1838
community.docker.docker_container:
1939
name: pulp_proxy
2040
image: nginx:stable-alpine
41+
network_mode: "{{ pulp_auth_proxy_network_mode }}"
2142
ports:
2243
- "{{ pulp_auth_proxy_listen_ip }}:{{ pulp_auth_proxy_listen_port }}:80"
2344
restart_policy: "no"

0 commit comments

Comments
 (0)