blob: bcd8258437d61c97cf04ac8ae605876207c51f50 (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
- import_role:
name: jail
tasks_from: jail_setup
# Override jail.conf with immich-specific version
- name: Deploy jail.conf.d/immich.conf
template:
src: "{{ jail_role_dir }}/templates/jail.conf.j2"
dest: /etc/jail.conf.d/immich.conf
owner: root
group: wheel
mode: "0644"
vars:
jail:
name: "{{ jail_name }}"
num: "{{ jail_num }}"
ip: "{{ jail_ips[jail_name] }}/{{ jail_lan_cidr | ipv4_prefixlen }}"
devfs_ruleset: "{{ devfs_ruleset | default(4) }}"
options: "{{ jail_conf_options | default([]) }}"
exec_prestart: "{{ exec_prestart | default([]) }}"
exec_start: "{{ exec_start | default([]) }}"
exec_poststart: "{{ exec_poststart | default([]) }}"
exec_prestop: "{{ exec_prestop | default([]) }}"
exec_stop: "{{ exec_stop | default([]) }}"
exec_poststop: "{{ exec_poststop | default([]) }}"
nullfs: "{{ nullfs | default([]) | normalize_nullfs }}"
delegate_to: "{{ jail_delegate_host }}"
# Fetch umoci Linux binary (statically linked, runs via Linux compat)
- name: Check if umoci is installed
stat:
path: /usr/local/bin/umoci
register: _umoci_stat
- name: Fetch umoci Linux binary
shell: |
fetch -o /tmp/umoci https://github.com/opencontainers/umoci/releases/latest/download/umoci.linux.amd64
install -m 755 /tmp/umoci /usr/local/bin/umoci
rm /tmp/umoci
when: not _umoci_stat.stat.exists
# Create /image directory
- name: Create /image directory
file:
path: /image
state: directory
owner: root
group: wheel
mode: "0755"
# Extract OCI images
- name: Check if images are extracted
stat:
path: "/image/{{ item.name }}{{ item.check_path }}"
loop: "{{ oci_images }}"
loop_control:
label: "{{ item.name }}"
register: _images_extracted
- name: Extract OCI images
shell: |
TMPDIR="/tmp/oci_extract_{{ item.item.name }}"
rm -rf "$TMPDIR"
mkdir -p "$TMPDIR"
skopeo copy --override-os linux "docker://{{ item.item.image }}" "oci:$TMPDIR/image"
umoci unpack --image "$TMPDIR/image" "$TMPDIR/unpacked"
rm -rf "/image/{{ item.item.name }}"
mv "$TMPDIR/unpacked/rootfs" "/image/{{ item.item.name }}"
rm -rf "$TMPDIR"
loop: "{{ _images_extracted.results }}"
loop_control:
label: "{{ item.item.name }}"
when: not item.stat.exists
- name: Create volume mount points in image rootfs
file:
path: "/image/{{ item[0].name }}{{ item[1].dst }}"
state: directory
owner: root
group: wheel
mode: "0755"
loop: "{{ oci_images | product(nullfs | default([]) | normalize_nullfs) | list }}"
loop_control:
label: "{{ item[0].name }}:{{ item[1].dst }}"
when: "item[1].dst.startswith('/image/' + item[0].name)"
- name: Deploy resolv.conf into image rootfs
copy:
content: "nameserver {{ lan_ipv4_gateway }}\n"
dest: "/image/{{ item.name }}/etc/resolv.conf"
owner: root
group: wheel
mode: "0644"
loop: "{{ oci_images }}"
loop_control:
label: "{{ item.name }}"
# Deploy rc.d scripts
- name: Deploy immich_server rc.d script
template:
src: "{{ jail_role_dir }}/templates/usr_local_etc_rc.d_immich_server"
dest: /usr/local/etc/rc.d/immich_server
owner: root
group: wheel
mode: "0755"
- name: Deploy immich_ml rc.d script
template:
src: "{{ jail_role_dir }}/templates/usr_local_etc_rc.d_immich_ml"
dest: /usr/local/etc/rc.d/immich_ml
owner: root
group: wheel
mode: "0755"
# Deploy env files
- name: Deploy immich_server.env
template:
src: "{{ jail_role_dir }}/templates/usr_local_etc_immich_server.env.j2"
dest: /usr/local/etc/immich_server.env
owner: root
group: wheel
mode: "0600"
notify: Restart immich services
- name: Deploy immich_ml.env
template:
src: "{{ jail_role_dir }}/templates/usr_local_etc_immich_ml.env.j2"
dest: /usr/local/etc/immich_ml.env
owner: root
group: wheel
mode: "0600"
notify: Restart immich services
# Enable services
- name: Enable immich services
community.general.sysrc:
name: "{{ item }}_enable"
value: "YES"
loop:
- immich_server
- immich_ml
- import_role:
name: jail
tasks_from: jail_launch
|