38 lines
1.1 KiB
YAML
38 lines
1.1 KiB
YAML
- name: Deploy Minecraft systemd service
|
|
ansible.builtin.template:
|
|
src: minecraft.service.j2
|
|
dest: "/etc/systemd/system/minecraft@.service"
|
|
register: minecraft_systemd
|
|
|
|
- name: Deploy service environmental variables
|
|
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
|
|
ansible.builtin.systemd:
|
|
daemon_reload: true
|
|
when: minecraft_systemd.changed
|
|
|
|
- name: Disable non-default service instances
|
|
ansible.builtin.service:
|
|
name: "minecraft@{{ item.name }}"
|
|
enabled: false
|
|
loop: "{{ minecraft }}"
|
|
when: item.name != minecraft_onboot
|
|
|
|
- name: Enable default service instance
|
|
ansible.builtin.service:
|
|
name: "minecraft@{{ minecraft_onboot }}"
|
|
enabled: true
|
|
when: minecraft_eula and minecraft_onboot is defined
|
|
|
|
- name: Run default service instance
|
|
ansible.builtin.service:
|
|
name: "minecraft@{{ minecraft_onboot }}"
|
|
state: started
|
|
when: minecraft_eula and minecraft_onboot is defined and minecraft_onboot_run
|