2021-06-17 02:49:01 +00:00
|
|
|
- name: Deploy Minecraft systemd service
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.template:
|
2021-06-17 02:49:01 +00:00
|
|
|
src: minecraft.service.j2
|
|
|
|
dest: "/etc/systemd/system/minecraft@.service"
|
|
|
|
register: minecraft_systemd
|
|
|
|
|
2021-06-22 02:36:35 +00:00
|
|
|
- name: Deploy service environmental variables
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.template:
|
2021-06-22 02:36:35 +00:00
|
|
|
src: environment.conf.j2
|
|
|
|
dest: "{{ minecraft_home }}/{{ item.name }}/environment.conf"
|
|
|
|
owner: "{{ minecraft_user }}"
|
|
|
|
group: "{{ minecraft_user }}"
|
|
|
|
loop: "{{ minecraft }}"
|
|
|
|
|
2021-06-17 02:49:01 +00:00
|
|
|
- name: Reload systemd manager configuration
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.systemd:
|
2021-06-17 02:49:01 +00:00
|
|
|
daemon_reload: true
|
|
|
|
when: minecraft_systemd.changed
|
|
|
|
|
2021-06-22 02:36:35 +00:00
|
|
|
- name: Disable non-default service instances
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.service:
|
2021-06-22 02:36:35 +00:00
|
|
|
name: "minecraft@{{ item.name }}"
|
|
|
|
enabled: false
|
|
|
|
loop: "{{ minecraft }}"
|
|
|
|
when: item.name != minecraft_onboot
|
|
|
|
|
|
|
|
- name: Enable default service instance
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.service:
|
2021-06-17 02:49:01 +00:00
|
|
|
name: "minecraft@{{ minecraft_onboot }}"
|
|
|
|
enabled: true
|
|
|
|
when: minecraft_eula and minecraft_onboot is defined
|
2021-06-22 02:36:35 +00:00
|
|
|
|
|
|
|
- name: Run default service instance
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.service:
|
2021-06-22 02:36:35 +00:00
|
|
|
name: "minecraft@{{ minecraft_onboot }}"
|
|
|
|
state: started
|
|
|
|
when: minecraft_eula and minecraft_onboot is defined and minecraft_onboot_run
|