{{ ansible_managed | comment }} # Infrastructure # Ansible instructions to deploy the infrastructure # Copyright (C) 2019-2020 Christoph (Sheogorath) Kern # Copyright (C) 2020 Saibotk # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . version: '2.1' services: minecraft: image: docker.io/itzg/minecraft-server:{{ minecraft_image_tag }} ports: - "{{ minecraft_server_port }}:25565" {% for item in minecraft_additional_ports %} - "{{ item }}" {% endfor %} volumes: - "{{ minecraft_data_location }}:/data" security_opt: - no-new-privileges environment: EULA: "TRUE" ENABLE_RCON: "{{ minecraft_enable_rcon | bool | lower }}" RCON_PASSWORD: "{{ minecraft_rcon_password }}" RCON_PORT: 28016 # enable env variable replacement REPLACE_ENV_VARIABLES: "TRUE" # define an optional prefix for your env variables you want to replace ENV_VARIABLE_PREFIX: "CFG_" {% for key, value in minecraft_config.items() %} {{ key | upper }}: "{{ value }}" {% endfor %} networks: minecraft-backend: restart: always {% if minecraft_enable_rcon_web %} rcon: image: docker.io/itzg/rcon labels: - "traefik.enable=true" - "traefik.http.routers.minecraft-websocket.rule=Host(`{{ minecraft_rcon_domain }}`) && PathPrefix(`/rcon-websocket`)" - "traefik.http.routers.minecraft-websocket.entrypoints=websecure" - "traefik.http.routers.minecraft-websocket.tls.certresolver={{ minecraft_rcon_certresolver }}" - "traefik.http.routers.minecraft-websocket.middlewares=minecraft,compress,minecraft-websocket-stripprefix" - "traefik.http.routers.minecraft-websocket.service=minecraft-websocket" - "traefik.http.services.minecraft-websocket.loadbalancer.server.port=4327" - "traefik.http.middlewares.minecraft-websocket-stripprefix.stripprefix.prefixes=/rcon-websocket" - "traefik.http.routers.minecraft.rule=Host(`{{ minecraft_rcon_domain }}`) && PathPrefix(`/`)" - "traefik.http.routers.minecraft.entrypoints=websecure" - "traefik.http.routers.minecraft.tls.certresolver={{ minecraft_rcon_certresolver }}" - "traefik.http.routers.minecraft.middlewares=minecraft,compress" - "traefik.http.routers.minecraft.service=minecraft" - "traefik.http.services.minecraft.loadbalancer.server.port=4326" - "traefik.http.middlewares.minecraft.headers.sslredirect=true" - "traefik.http.middlewares.minecraft.headers.stsSeconds=63072000" - "traefik.http.middlewares.minecraft.headers.referrerPolicy=no-referrer" {% if proxy_network is defined %} - "traefik.docker.network={{ proxy_network }}" {% endif %} volumes: - "{{ minecraft_rcon_location }}:/opt/rcon-web-admin/db" networks: minecraft-backend: {% if proxy_network is defined %} {{ proxy_network }}: {% endif %} restart: always {% endif %} {% if minecraft_telegraf.enabled %} telegraf: image: docker.io/library/telegraf:{{ minecraft_telegraf_image_version }} restart: always mem_limit: 256mb memswap_limit: 384mb read_only: false # TODO: Switch to self-made container networks: minecraft-backend: volumes: - {{ minecraft_telegraf_location }}:/etc/telegraf/:ro {% endif %} networks: minecraft-backend: driver: bridge {% if minecraft_ipv6 is defined and minecraft_ipv6.enabled %} ipam: driver: default config: - subnet: {{ minecraft_ipv6.subnet }} enable_ipv6: true {% endif %} {% if proxy_network is defined and minecraft_enable_rcon_web %} {{ proxy_network }}: external: true {% endif %}