From e9f855897e19d6d1c55815a456dfc9fadf831215 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 1 Oct 2020 10:34:39 +0200 Subject: [PATCH] add option to expose ports --- defaults/main.yml | 7 +++++++ templates/services/droneci_autoscaler_compose.yml.j2 | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index 36aa1b9..4d4f10f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -58,6 +58,7 @@ droneci_autoscaler_instances: [] # agent_concurrency: 15 # agent_architecture: amd64 # sshkey: "dummy" +# api_host: "drone-amd64.example.com" # provider_config: # - name: DRONE_HETZNERCLOUD_DATACENTER # value: fsn1 @@ -111,5 +112,11 @@ droneci_autoscaler_networks: - name: droneci_default external: True +# @var droneci_autoscaler_exposed_ports: $ "_unset_" +# @var droneci_autoscaler_exposed_ports:example: > +# droneci_autoscaler_exposed_ports: +# - "8080:8080" +# @end + droneci_autoscaler_networks_applied: - droneci_default diff --git a/templates/services/droneci_autoscaler_compose.yml.j2 b/templates/services/droneci_autoscaler_compose.yml.j2 index 4ec5178..a59152b 100644 --- a/templates/services/droneci_autoscaler_compose.yml.j2 +++ b/templates/services/droneci_autoscaler_compose.yml.j2 @@ -7,6 +7,12 @@ services: container_name: {{ inst.name }} image: {{ droneci_autoscaler_image }} restart: {{ droneci_autoscaler_restart_policy }} + {% if droneci_autoscaler_exposed_ports | default([]) %} + ports: + {% for port in droneci_autoscaler_exposed_ports %} + - {{ port | quote }} + {% endfor %} + {% endif %} volumes: - "{{ __droneci_autoscaler_workdir }}/userdata.yml:/etc/scaler/userdata.yml:Z" - "{{ __droneci_autoscaler_workdir }}/ssh_key:/root/.ssh/id_rsa:ro,Z" @@ -44,6 +50,9 @@ services: {% if inst.agent_volumes | default(droneci_autoscaler_agent_volumes) | default(False) %} - DRONE_AGENT_VOLUMES={{ inst.agent_volumes | default(droneci_autoscaler_agent_volumes) | join(",") }} {% endif %} + {% if inst.api_host is defined %} + - DRONE_HTTP_HOST={{ inst.api_host }} + {% endif %} {% if inst.runner_volumes | default(droneci_autoscaler_runner_volumes) | default(False) %} - DRONE_RUNNER_VOLUMES={{ inst.runner_volumes | default(droneci_autoscaler_runner_volumes) | join(",") }} {% endif %}