homelab/roles/minecraft/tasks/main.yml

28 lines
742 B
YAML

- name: Create minecraft volume
become: true
community.docker.docker_volume:
name: minecraft
- name: Create minecraft container
become: true
community.docker.docker_container:
name: minecraft
image: itzg/minecraft-server:stable
ports:
- "25565:25565"
user: "1003:972"
env:
EULA: "{{ eula | string }}"
TYPE: "{{ server_type }}"
VERSION: "{{ server_version }}"
DIFFICULTY: "{{ difficulty }}"
ONLINE_MODE: "{{ online_mode | string }}"
SERVER_NAME: "{{ server_name }}"
TZ: "{{ tz }}"
volumes:
- minecraft:/data
healthcheck:
test: ["CMD", "mc-health"]
interval: 30s
start_period: 2m
retries: 2
restart_policy: unless-stopped