homelab/roles/minecraft/tasks/service.yml

38 lines
1.1 KiB
YAML
Raw Normal View History

- name: Deploy Minecraft systemd service
2023-05-04 03:27:03 +00:00
ansible.builtin.template:
src: minecraft.service.j2
dest: "/etc/systemd/system/minecraft@.service"
register: minecraft_systemd
- name: Deploy service environmental variables
2023-05-04 03:27:03 +00:00
ansible.builtin.template:
src: environment.conf.j2
dest: "{{ minecraft_home }}/{{ item.name }}/environment.conf"
owner: "{{ minecraft_user }}"
group: "{{ minecraft_user }}"
loop: "{{ minecraft }}"
- name: Reload systemd manager configuration
2023-05-04 03:27:03 +00:00
ansible.builtin.systemd:
daemon_reload: true
when: minecraft_systemd.changed
- name: Disable non-default service instances
2023-05-04 03:27:03 +00:00
ansible.builtin.service:
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:
name: "minecraft@{{ minecraft_onboot }}"
enabled: true
when: minecraft_eula and minecraft_onboot is defined
- name: Run default service instance
2023-05-04 03:27:03 +00:00
ansible.builtin.service:
name: "minecraft@{{ minecraft_onboot }}"
state: started
when: minecraft_eula and minecraft_onboot is defined and minecraft_onboot_run