xoxys.droneci_autoscaler/templates/services/droneci_autoscaler_compose.yml.j2

90 lines
4.9 KiB
Plaintext
Raw Normal View History

2020-09-30 19:56:00 +00:00
#jinja2:lstrip_blocks: True
{{ ansible_managed | comment }}
version: "2.4"
services:
droneci_autoscaler_{{ inst.name }}:
container_name: {{ droneci_autoscaler_container_name }}
image: {{ droneci_autoscaler_image }}
restart: {{ droneci_autoscaler_restart_policy }}
volumes:
- "{{ __droneci_autoscaler_workdir }}/userdata.yml:/etc/scaler/userdata.yml"
- "{{ __droneci_autoscaler_workdir }}/ssh_key:/root/.ssh/id_rsa:ro"
{% for volume in droneci_autoscaler_volumes %}
- "{{ volume.name }}:{{ volume.dest }}"
{% endfor %}
{% if droneci_autoscaler_networks_applied | default([]) %}
networks:
{% for network in droneci_autoscaler_networks_applied %}
- {{ network }}
{% endfor %}
{% endif %}
environment:
- DRONE_INTERVAL={{ inst.interval | default(droneci_autoscaler_interval) }}
{% if (inst.slack_webhook | default(droneci_autoscaler_slack_webhook)) is defined %}
- DRONE_SLACK_WEBHOOK={{ inst.slack_webhook | default(droneci_autoscaler_slack_webhook) }}
- DRONE_SLACK_CREATE={{ (inst.slack_create | default(droneci_autoscaler_slack_create)) | bool | lower }}
- DRONE_SLACK_DESTROY={{ (inst.slack_destroy | default(droneci_autoscaler_slack_destroy)) | bool | lower }}
- DRONE_SLACK_ERROR={{ (inst.slack_error | default(droneci_autoscaler_slack_error)) | bool | lower }}
{% endif %}
- DRONE_LOGS_COLOR={{ (inst.logs_color | default(droneci_autoscaler_logs_color)) | bool | lower }}
- DRONE_LOGS_PRETTY={{ (inst.logs_pretty | default(droneci_autoscaler_logs_pretty)) | bool | lower }}
- DRONE_LOGS_DEBUG={{ (inst.logs_debug | default(droneci_autoscaler_logs_debug)) | bool | lower }}
- DRONE_POOL_MIN={{ inst.pool_min | default(droneci_autoscaler_pool_min) }}
- DRONE_POOL_MAX={{ inst.pool_max | default(droneci_autoscaler_pool_max) }}
- DRONE_POOL_MIN_AGE={{ inst.pool_ttl | default(droneci_autoscaler_pool_ttl) }}
- DRONE_SERVER_HOST={{ droneci_autoscaler_server_host }}
- DRONE_SERVER_PROTO={{ droneci_autoscaler_server_proto }}
- DRONE_SERVER_TOKEN={{ droneci_autoscaler_server_token }}
- DRONE_AGENT_TOKEN={{ inst.agent_token | default(droneci_autoscaler_agent_token) }}
- DRONE_AGENT_IMAGE={{ inst.agent_image | default(droneci_autoscaler_agent_image) }}
- DRONE_AGENT_CONCURRENCY={{ inst.agent_concurrency | default(droneci_autoscaler_agent_concurrency) }}
- DRONE_AGENT_OS={{ inst.agent_os | default(droneci_autoscaler_agent_os) }}
- DRONE_AGENT_ARCH={{ inst.agent_architecture | default(droneci_autoscaler_agent_architecture) }}
{% 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.runner_volumes | default(droneci_autoscaler_runner_volumes) | default(False) %}
- DRONE_RUNNER_VOLUMES={{ inst.runner_volumes | default(droneci_autoscaler_runner_volumes) | join(",") }}
{% endif %}
- DRONE_RUNNER_PRIVILEGED_IMAGES={{ inst.runner_privileged | default(droneci_autoscaler_runner_privileged) | join(",") }}
- DRONE_GC_ENABLED={{ (inst.gc_enabled | default(droneci_autoscaler_gc_enabled)) | bool | lower }}
- DRONE_GC_DEBUG=false
- DRONE_REAPER_ENABLED=true
- DRONE_REAPER_INTERVAL=30m
- DRONE_WATCHTOWER_ENABLED={{ (inst.watchtower_enabled | default(droneci_autoscaler_watchtower_enabled)) | bool | lower }}
{% if (inst.prometheus_token | default(droneci_autoscaler_prometheus_token)) is defined %}
- DRONE_PROMETHEUS_AUTH_TOKEN={{ inst.prometheus_token | default(droneci_autoscaler_prometheus_token) }}
{% endif %}
{% if droneci_autoscaler_db_type == "pgsql" %}
- DRONE_DATABASE_DRIVER=postgres
- DRONE_DATABASE_DATASOURCE=postgres://{{ droneci_autoscaler_db_user }}:{{ droneci_autoscaler_db_password }}@{{ droneci_autoscaler_db_server }}/{{ droneci_autoscaler_db_name }}?sslmode={{ droneci_autoscaler_db_ssl_mode }}
{% endif %}
{% for item in inst.provider_config %}
- {{ item.name | upper }}={{ item.value }}
{% endfor %}
{% if droneci_autoscaler_memory_limit is defined %}
mem_limit: {{ droneci_autoscaler_memory_limit }}
{% endif %}
{% if droneci_autoscaler_memory_reservation is defined %}
mem_reservation: {{ droneci_autoscaler_memory_reservation }}
{% endif %}
{% if droneci_autoscaler_networks | default([]) | length > 0 %}
{% if droneci_autoscaler_volumes | default([]) | rejectattr("bind") | list | length > 0 %}
volumes:
{% for volume in droneci_autoscaler_volumes | rejectattr("bind") %}
{{ volume.name }}:
{% endfor %}
{% endif %}
networks:
{% for network in droneci_autoscaler_networks %}
{{ network.name }}:
{% if network.external | default(False) | bool %}
external: true
{% else %}
driver: {{ network.backend | default("bridge") }}
{% endif %}
{% endfor %}
{% endif %}