-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yaml
More file actions
71 lines (61 loc) · 1.78 KB
/
Copy pathplaybook.yaml
File metadata and controls
71 lines (61 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
- name: Deploy Minecraft container
hosts: all
vars:
container_user: ec2-user
remote_user: "{{ container_user }}"
become: true
tasks:
- name: Find uid
command: "id -u {{ container_user }}"
register: container_user_uid
check_mode: false
changed_when: false
# This hangs indefinitely for some reason
# - name: Ensure podman is installed
# ansible.builtin.package:
# name: podman
- name: Ensure podman is installed
become: true
ansible.builtin.command:
cmd: dnf install podman -y
timeout: 90
ignore_errors: true
- name: Create Quadlet dir
ansible.builtin.file:
path: /home/{{container_user}}/.config/containers/systemd
recurse: true
state: directory
owner: ec2-user
group: ec2-user
mode: '0755'
- name: Copy the Quadlet files
ansible.builtin.copy:
src: quadlets/
dest: /home/{{container_user}}/.config/containers/systemd
owner: ec2-user
group: ec2-user
mode: '0644'
- name: Check if user is lingering
stat:
path: "/var/lib/systemd/linger/{{ container_user }}"
register: user_lingering
- name: Enable lingering is needed
command: "loginctl enable-linger {{ container_user }}"
when:
- not user_lingering.stat.exists
- name: Reload daemon to generate unit files
become_user: "{{container_user}}"
ansible.builtin.systemd:
scope: user
daemon_reload: true
environment:
XDG_RUNTIME_DIR: "/run/user/{{ container_user_uid.stdout }}"
- name: Start Minecraft service
become_user: "{{container_user}}"
ansible.builtin.systemd:
name: minecraft.service
scope: user
enabled: true
state: started
environment:
XDG_RUNTIME_DIR: "/run/user/{{ container_user_uid.stdout }}"