minecraft/tasks/main.yaml
changeset 112 22c06d6916bf
parent 111 1c1a911b26aa
child 125 5a298f7b44f5
equal deleted inserted replaced
111:1c1a911b26aa 112:22c06d6916bf
       
     1 ---
       
     2 
       
     3 - name: add minecraft user
       
     4   become: yes
       
     5   user: name="{{minecraft_user}}" home="{{minecraft_dir}}"
       
     6 
       
     7 - name: install jre
       
     8   become: yes
       
     9   apt: name="default-jre-headless"
       
    10 
       
    11 - name: set minecraft fork
       
    12   set_fact: minecraft_url="{{minecraft_vanilla_url}}"
       
    13   when: minecraft_fork == "vanilla"
       
    14 
       
    15 - name: set minecraft fork
       
    16   set_fact: minecraft_url="{{minecraft_paper_url}}"
       
    17   when: minecraft_fork == "paper"
       
    18 
       
    19 - name: create minecraft dir
       
    20   become: yes
       
    21   file:
       
    22     path: "{{minecraft_dir}}"
       
    23     owner: "{{minecraft_user}}"
       
    24     group: "{{minecraft_user}}"
       
    25     mode: "0755"
       
    26     state: "directory"
       
    27 
       
    28 - name: download minecraft
       
    29   become: yes
       
    30   get_url:
       
    31     url: "{{minecraft_url}}"
       
    32     dest: "{{minecraft_dir}}/server.jar"
       
    33     mode: "0755"
       
    34   notify: restart minecraft
       
    35 
       
    36 - name: configure minecraft eula and ops
       
    37   become: yes
       
    38   copy:
       
    39     src: "{{item}}"
       
    40     dest: "{{minecraft_dir}}/{{item}}"
       
    41     owner: "{{minecraft_user}}"
       
    42     group: "{{minecraft_user}}"
       
    43   loop:
       
    44     - "eula.txt"
       
    45     - "ops.json"
       
    46   notify: restart minecraft
       
    47 
       
    48 - name: create server.properties
       
    49   become: yes
       
    50   file:
       
    51     path: "{{minecraft_dir}}/server.properties"
       
    52     state: "touch"
       
    53     access_time: "preserve"
       
    54     modification_time: "preserve"
       
    55     owner: "{{minecraft_user}}"
       
    56     group: "{{minecraft_user}}"
       
    57 
       
    58 - name: configure server.properties
       
    59   become: yes
       
    60   lineinfile:
       
    61     path: "{{minecraft_dir}}/server.properties"
       
    62     regexp: "^{{item.key}}="
       
    63     line: "{{item.key}}={{item.value}}"
       
    64   notify: restart minecraft
       
    65   loop:
       
    66     - {key: "motd", value: "{{minecraft_motd}}"}
       
    67     - {key: "level-seed", value: "{{minecraft_seed}}"}
       
    68 
       
    69 - name: install systemd service
       
    70   become: yes
       
    71   template:
       
    72     src: "minecraft.service.j2"
       
    73     dest: "/lib/systemd/system/minecraft.service"
       
    74   notify: restart minecraft
       
    75 
       
    76 - name: ensure service is started
       
    77   become: yes
       
    78   systemd: name="minecraft.service" enabled="yes" state="started"