diff --git a/roles/pgadmin/README.md b/roles/pgadmin/README.md index abbe8406..94b4e476 100644 --- a/roles/pgadmin/README.md +++ b/roles/pgadmin/README.md @@ -38,6 +38,8 @@ The role will: | `pgadmin_default_email` | `str` | `False` | `pgadmin@cloudera-labs.com` | Email account for the default user to access the pgAdmin web UI. This user is created on first launch of the container. | | `pgadmin_default_password` | `str` | `False` | `pgadmin` | Password for the default user to access the pgAdmin web UI. **It is highly recommended to change this default password for production environments.** | | `pgadmin_docker_exe` | `str` | `False` | `/usr/bin/docker` | The full path to the Docker executable on the target host. | +| `pgadmin_docker_network_subnet_cidr` | `str` | `False` | `172.21.0.0/16` | Subnet CIDR for the Docker bridge network used by pgadmin. | +| `pgadmin_docker_network_subnet_gateway` | `str` | `False` | `172.21.0.1` | Gateway for the Docker bridge network subnet used by pgadmin. | # Example Playbook diff --git a/roles/pgadmin/defaults/main.yml b/roles/pgadmin/defaults/main.yml index 6b0faa8a..5c374fe7 100644 --- a/roles/pgadmin/defaults/main.yml +++ b/roles/pgadmin/defaults/main.yml @@ -38,3 +38,6 @@ pgadmin_default_email: "pgadmin@cloudera-labs.com" pgadmin_default_password: "pgadmin" pgadmin_docker_exe: /usr/bin/docker + +pgadmin_docker_network_subnet_cidr: 172.21.0.0/16 +pgadmin_docker_network_subnet_gateway: 172.21.0.1 diff --git a/roles/pgadmin/meta/argument_specs.yml b/roles/pgadmin/meta/argument_specs.yml index af6211aa..ffac5e65 100644 --- a/roles/pgadmin/meta/argument_specs.yml +++ b/roles/pgadmin/meta/argument_specs.yml @@ -81,3 +81,13 @@ argument_specs: type: str required: false default: "/usr/bin/docker" + pgadmin_docker_network_subnet_cidr: + description: Subnet CIDR for the Docker bridge network used by pgadmin. + type: str + required: false + default: "172.21.0.0/16" + pgadmin_docker_network_subnet_gateway: + description: Gateway for the Docker bridge network subnet used by pgadmin. + type: str + required: false + default: "172.21.0.1" diff --git a/roles/pgadmin/templates/pgadmin-docker-compose.yml.j2 b/roles/pgadmin/templates/pgadmin-docker-compose.yml.j2 index 39f07881..be3b0a5c 100644 --- a/roles/pgadmin/templates/pgadmin-docker-compose.yml.j2 +++ b/roles/pgadmin/templates/pgadmin-docker-compose.yml.j2 @@ -3,6 +3,8 @@ services: image: dpage/pgadmin4:latest container_name: pgadmin4_container restart: always + networks: + - pg_network ports: - "{{ pgadmin_port }}:80" entrypoint: /bin/sh -c "chmod 600 /pgpass; /entrypoint.sh;" @@ -19,3 +21,11 @@ services: volumes: pgadmin-data: + +networks: + pg_network: + driver: bridge + ipam: + config: + - subnet: {{ pgadmin_docker_network_subnet_cidr }} + gateway: {{ pgadmin_docker_network_subnet_gateway }}