91 lines
2.8 KiB
Django/Jinja
91 lines
2.8 KiB
Django/Jinja
#jinja2:lstrip_blocks: True
|
|
{{ ansible_managed | comment }}
|
|
version: "2.4"
|
|
|
|
services:
|
|
homeassistant:
|
|
container_name: {{ homeassistant_container_name }}
|
|
image: {{ homeassistant_image }}
|
|
restart: {{ homeassistant_restart_policy }}
|
|
{% if homeassistant_exposed_ports | default([]) %}
|
|
ports:
|
|
{% for port in homeassistant_exposed_ports %}
|
|
- {{ port | quote }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if homeassistant_volumes | default([]) %}
|
|
volumes:
|
|
{% for volume in homeassistant_volumes %}
|
|
- "{{ volume.name }}:{{ volume.dest }}{% if volume.bind_opt is defined %}:{{ volume.bind_opt }}{% endif %}"
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if homeassistant_devices | default([]) %}
|
|
devices:
|
|
{% for device in homeassistant_devices %}
|
|
- "{{ device.src }}:{{ device.dest }}{% if device.opt is defined %}:{{ device.opt }}{% endif %}"
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if homeassistant_networks_applied | default([]) %}
|
|
networks:
|
|
{% for network in homeassistant_networks_applied %}
|
|
- {{ network }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if homeassistant_extra_hosts | default([]) %}
|
|
extra_hosts:
|
|
{% for host in homeassistant_extra_hosts %}
|
|
- {{ host | quote }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
environment:
|
|
- TZ={{ homeassistant_timezone }}
|
|
{% if homeassistant_memory_limit is defined %}
|
|
mem_limit: {{ homeassistant_memory_limit }}
|
|
{% endif %}
|
|
{% if homeassistant_memory_reservation is defined %}
|
|
mem_reservation: {{ homeassistant_memory_reservation }}
|
|
{% endif %}
|
|
{% if homeassistant_cpu_shares is defined %}
|
|
cpu_shares: {{ homeassistant_cpu_shares }}
|
|
{% endif %}
|
|
{% if not homeassistant_cap_add | length == 0 %}
|
|
cap_add:
|
|
{% for item in homeassistant_cap_add %}
|
|
- {{ item }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if not homeassistant_cap_drop | length == 0 %}
|
|
cap_drop:
|
|
{% for item in homeassistant_cap_drop %}
|
|
- {{ item }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if not homeassistant_security_opt | length == 0 %}
|
|
security_opt:
|
|
{% for item in homeassistant_security_opt %}
|
|
- {{ item }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if homeassistant_pids_limit is defined %}
|
|
pids_limit: {{ homeassistant_pids_limit }}
|
|
{% endif %}
|
|
{% if homeassistant_volumes | default([]) | rejectattr("bind") | list | length > 0 %}
|
|
|
|
volumes:
|
|
{% for volume in homeassistant_volumes | rejectattr("bind") %}
|
|
{{ volume.name }}:
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if homeassistant_networks | default([]) | length > 0 %}
|
|
|
|
networks:
|
|
{% for network in homeassistant_networks %}
|
|
{{ network.name }}:
|
|
{% if network.external | default(False) | bool %}
|
|
external: true
|
|
{% else %}
|
|
driver: {{ network.backend | default("bridge") }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|