diff --git a/roles/minetest/tasks/enable.yml b/roles/minetest/tasks/enable.yml new file mode 100644 index 000000000..170b51629 --- /dev/null +++ b/roles/minetest/tasks/enable.yml @@ -0,0 +1,36 @@ +# enable or disable +- name: Enable & Restart 'minetest-server' service + systemd: + daemon_reload: yes + name: minetest-server + enabled: yes + state: restarted + when: minetest_enabled | bool + +- name: Disable 'minetest-server' service + systemd: + daemon_reload: yes + name: minetest-server + enabled: no + state: stopped + when: not minetest_enabled + +- name: Add 'minetest' variable values to {{ iiab_ini_file }} + ini_file: + path: "{{ iiab_ini_file }}" + section: minetest + option: "{{ item.option }}" + value: "{{ item.value }}" + with_items: + - option: name + value: Minetest Server + - option: description + value: '"Minetest is an open source clone of the Minecraft building blocks game."' + - option: minetest_world_dir + value: "{{ minetest_world_dir }}" + - option: minetest_port + value: "{{ minetest_port }}" + - option: minetest_enabled + value: "{{ minetest_enabled }}" + - option: minetest_world_dir + value: "{{ minetest_world_dir }}" diff --git a/roles/minetest/tasks/main.yml b/roles/minetest/tasks/main.yml index 042dccde9..320079d06 100644 --- a/roles/minetest/tasks/main.yml +++ b/roles/minetest/tasks/main.yml @@ -1,109 +1,5 @@ -# Calculate local variables -- include_tasks: calc_vars.yml +- include_tasks: provision.yml + when: minetest_install and not minetest_installed is defined -- name: Check for minetest world file ({{ minetest_world_dir }}/world.mt) - stat: - path: "{{ minetest_world_dir }}/world.mt" - register: minetest_world - -- name: Create /library/games - file: - state: directory - path: "{{ item }}" - owner: root - group: root - mode: 0755 - with_items: - - /library/games - -# rpi only -- include_tasks: rpi_minetest_install.yml - when: not minetest_world.stat.exists and is_rpi - -# not rpi -- include_tasks: minetest_install.yml - when: not minetest_world.stat.exists and not is_rpi - -- git: - repo: https://github.com/Calinou/carbone-ng.git - dest: "{{ minetest_game_dir }}" - depth: 1 - when: not minetest_world.stat.exists and minetest_default_game == "carbone-ng" - -- name: Give minetest user ownership of carbone-ng - file: - state: directory - path: "{{ minetest_game_dir }}" - recurse: yes - owner: "{{ minetest_runas_user }}" - group: "{{ minetest_runas_group }}" - mode: 0755 - when: minetest_default_game == "carbone-ng" - -# Install games -#- include: minetest_install_games.yml -# with_items: -# - name: carbone-ng -# url: https://github.com/Calinou/carbone-ng - -# Install mods -- include: minetest_install_mods.yml - with_items: - - name: moreblocks - url: https://github.com/minetest-mods/moreblocks/archive/master.zip - - name: moreores - url: https://github.com/Calinou/moreores/archive/master.zip - - name: basic_materials - url: https://gitlab.com/VanessaE/basic_materials/-/archive/master/basic_materials-master.zip - - name: mesecons - url: https://github.com/minetest-mods/mesecons/archive/master.zip - - name: digilines - url: https://github.com/minetest-mods/digilines/archive/master.zip - - name: pipeworks - url: https://github.com/minetest-mods/pipeworks/archive/master.zip - - name: Minetest-WorldEdit - url: https://github.com/Uberi/Minetest-WorldEdit/archive/master.zip - when: minetest_default_game == "minetest" - -- name: Remove mod from carbone-ng that prevents our Admin name - file: - state: absent - path: "{{ minetest_game_dir }}/mods/name_restrictions" - when: minetest_default_game == "carbone-ng" - -# enable or disable -- name: Enable & Restart 'minetest-server' service - systemd: - daemon_reload: yes - name: minetest-server - enabled: yes - state: restarted - when: minetest_enabled | bool - -- name: Disable 'minetest-server' service - systemd: - daemon_reload: yes - name: minetest-server - enabled: no - state: stopped - when: not minetest_enabled - -- name: Add 'minetest' variable values to {{ iiab_ini_file }} - ini_file: - path: "{{ iiab_ini_file }}" - section: minetest - option: "{{ item.option }}" - value: "{{ item.value }}" - with_items: - - option: name - value: Minetest Server - - option: description - value: '"Minetest is an open source clone of the Minecraft building blocks game."' - - option: minetest_world_dir - value: "{{ minetest_world_dir }}" - - option: minetest_port - value: "{{ minetest_port }}" - - option: minetest_enabled - value: "{{ minetest_enabled }}" - - option: minetest_world_dir - value: "{{ minetest_world_dir }}" +- include_tasks: enable.yml + when: minetest_install or minetest_installed is defined diff --git a/roles/minetest/tasks/provision.yml b/roles/minetest/tasks/provision.yml new file mode 100644 index 000000000..6d19d6010 --- /dev/null +++ b/roles/minetest/tasks/provision.yml @@ -0,0 +1,80 @@ +# Calculate local variables +- include_tasks: calc_vars.yml + +- name: Check for minetest world file ({{ minetest_world_dir }}/world.mt) + stat: + path: "{{ minetest_world_dir }}/world.mt" + register: minetest_world + +- name: Create /library/games + file: + state: directory + path: "{{ item }}" + owner: root + group: root + mode: 0755 + with_items: + - /library/games + +# rpi only +- include_tasks: rpi_minetest_install.yml + when: not minetest_world.stat.exists and is_rpi + +# not rpi +- include_tasks: minetest_install.yml + when: not minetest_world.stat.exists and not is_rpi + +- git: + repo: https://github.com/Calinou/carbone-ng.git + dest: "{{ minetest_game_dir }}" + depth: 1 + when: not minetest_world.stat.exists and minetest_default_game == "carbone-ng" + +- name: Give minetest user ownership of carbone-ng + file: + state: directory + path: "{{ minetest_game_dir }}" + recurse: yes + owner: "{{ minetest_runas_user }}" + group: "{{ minetest_runas_group }}" + mode: 0755 + when: minetest_default_game == "carbone-ng" + +# Install games +#- include: minetest_install_games.yml +# with_items: +# - name: carbone-ng +# url: https://github.com/Calinou/carbone-ng + +# Install mods +- include: minetest_install_mods.yml + with_items: + - name: moreblocks + url: https://github.com/minetest-mods/moreblocks/archive/master.zip + - name: moreores + url: https://github.com/Calinou/moreores/archive/master.zip + - name: basic_materials + url: https://gitlab.com/VanessaE/basic_materials/-/archive/master/basic_materials-master.zip + - name: mesecons + url: https://github.com/minetest-mods/mesecons/archive/master.zip + - name: digilines + url: https://github.com/minetest-mods/digilines/archive/master.zip + - name: pipeworks + url: https://github.com/minetest-mods/pipeworks/archive/master.zip + - name: Minetest-WorldEdit + url: https://github.com/Uberi/Minetest-WorldEdit/archive/master.zip + when: minetest_default_game == "minetest" + +- name: Remove mod from carbone-ng that prevents our Admin name + file: + state: absent + path: "{{ minetest_game_dir }}/mods/name_restrictions" + when: minetest_default_game == "carbone-ng" + +- name: Add 'minetest_installed' variable values to {{ iiab_installed }} + lineinfile: + dest: "{{ iiab_installed }}" + regexp: '^minetest_installed' + line: 'minetest_installed: True' + state: present +