aboutsummaryrefslogtreecommitdiffstats
path: root/roles/jails/20_immich/tasks/main.yml
blob: 835cd50e661922d34a3844f5d64563de98adf8a2 (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
- 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"
  delegate_to: "{{ jail_delegate_host }}"

# Deploy extraction script
- name: Deploy extract-image script
  template:
    src: "{{ jail_role_dir }}/templates/usr_local_bin_extract_image.sh"
    dest: /usr/local/bin/extract-image.sh
    owner: root
    group: wheel
    mode: "0755"

# 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: "/usr/local/bin/extract-image.sh {{ item.item.image }} {{ item.item.name }}"
  loop: "{{ _images_extracted.results }}"
  loop_control:
    label: "{{ item.item.name }}"
  when: not item.stat.exists

# Create mount points in each rootfs
- name: Create base mount points in image rootfs
  file:
    path: "/image/{{ item[0].name }}/{{ item[1] }}"
    state: directory
    owner: root
    group: wheel
    mode: "0755"
  loop: "{{ oci_images | product(['proc', 'sys', 'dev', 'tmp', 'run']) | list }}"
  loop_control:
    label: "{{ item[0].name }}/{{ item[1] }}"

- name: Create nullfs 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 | subelements('mounts', skip_missing=True) }}"
  loop_control:
    label: "{{ item.0.name }}:{{ item.1.dst }}"

# Deploy resolv.conf into each rootfs
- 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