minecraft/server/tasks/main.yaml
changeset 164 ae19501f5251
parent 163 40b78af86337
child 174 431c6d5e5dd4
equal deleted inserted replaced
163:40b78af86337 164:ae19501f5251
     1 ---
     1 ---
     2 
     2 
     3 - name: add minecraft user
     3 - name: add minecraft user
     4   become: yes
     4   become: yes
     5   user: name="{{minecraft_user}}" home="{{minecraft_dir}}"
     5   user: name="{{minecraft_user}}" home="{{minecraft_parent_dir}}/minecraft"
     6 
     6 
     7 - name: install adoptopenjdk
     7 - name: install adoptopenjdk
     8   include_tasks: adoptopenjdk.yaml
     8   include_tasks: adoptopenjdk.yaml
     9 
       
    10 - name: set minecraft fork
       
    11   set_fact: minecraft_url="{{minecraft_vanilla_url}}"
       
    12   when: minecraft_fork == "vanilla"
       
    13 
       
    14 - name: set minecraft fork
       
    15   set_fact: minecraft_url="{{minecraft_paper_url}}"
       
    16   when: minecraft_fork == "paper"
       
    17 
     9 
    18 - name: create minecraft dir
    10 - name: create minecraft dir
    19   become: yes
    11   become: yes
    20   file:
    12   file:
    21     path: "{{minecraft_dir}}"
    13     path: "{{minecraft_dir}}"
    70     mode: "0755"
    62     mode: "0755"
    71     state: "directory"
    63     state: "directory"
    72 
    64 
    73 - name: install plugins
    65 - name: install plugins
    74   include_tasks: "{{item}}.yaml"
    66   include_tasks: "{{item}}.yaml"
    75   loop: "{{minecreat_paper_plugins_enabled}}"
    67   loop: "{{minecreat_plugins_enabled}}"
    76   when: minecraft_fork == "paper"
       
    77 
    68 
    78 - name: create server.properties
    69 - name: create server.properties
    79   become: yes
    70   become: yes
    80   file:
    71   file:
    81     path: "{{minecraft_dir}}/server.properties"
    72     path: "{{minecraft_dir}}/server.properties"
    92     regexp: "^{{item.key}}="
    83     regexp: "^{{item.key}}="
    93     line: "{{item.key}}={{item.value}}"
    84     line: "{{item.key}}={{item.value}}"
    94   notify: restart minecraft
    85   notify: restart minecraft
    95   loop:
    86   loop:
    96     - {key: "motd", value: "{{minecraft_motd}}"}
    87     - {key: "motd", value: "{{minecraft_motd}}"}
       
    88     - {key: "level-name", value: "{{minecraft_world_name}}"}
    97     - {key: "level-seed", value: "{{minecraft_seed}}"}
    89     - {key: "level-seed", value: "{{minecraft_seed}}"}
    98     - {key: "difficulty", value: "{{minecraft_difficulty}}"}
    90     - {key: "difficulty", value: "{{minecraft_difficulty}}"}
    99     - {key: "white-list", value: "{{minecraft_whitelist}}"}
    91     - {key: "white-list", value: "{{minecraft_whitelist}}"}
   100     - {key: "enforce-whitelist", value: "{{minecraft_whitelist}}"}
    92     - {key: "enforce-whitelist", value: "{{minecraft_whitelist}}"}
   101     - {key: "view-distance", value: "{{minecraft_view_distance}}"}
    93     - {key: "view-distance", value: "{{minecraft_view_distance}}"}
   102     - {key: "snooper-enabled", value: "false"}
    94     - {key: "snooper-enabled", value: "false"}
   103 
    95 
   104 - name: install systemd service
    96 - name: install systemd service
   105   become: yes
    97   become: yes
   106   template:
    98   template:
   107     src: "minecraft.service.j2"
    99     src: "[email protected]"
   108     dest: "/lib/systemd/system/minecraft.service"
   100     dest: "/lib/systemd/system/[email protected]"
   109   notify: restart minecraft
   101   notify: restart minecraft
   110 
   102 
   111 - name: ensure service is started
   103 - name: ensure service is started
   112   become: yes
   104   become: yes
   113   systemd: name="minecraft.service" enabled="yes" state="started"
   105   systemd: name="minecraft@{{minecraft_world_name}}.service" enabled="yes" state="started"