Skip to content

Commit

Permalink
unionfs: use bash script to run mergerfs to avoid systemd line length…
Browse files Browse the repository at this point in the history
… limitation with many remotes
  • Loading branch information
saltydk committed Jul 28, 2024
1 parent e171597 commit 22bd09f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
14 changes: 1 addition & 13 deletions roles/unionfs/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ mergerfs_mount_start_command: |-
-o dropcacheonclose=true,minfreespace=0,fsname=mergerfs \
-o xattr={{ mergerfs_mount_xattr }},statfs=base,statfs_ignore=nc,umask={{ mergerfs_mount_umask }},noatime \
-o func.readdir={{ mergerfs_mount_readdir_policy }} \
{% set branches = mergerfs_mount_branches.split(':') %}
{%- for branch in branches %}
{% if loop.index0 is divisibleby 10 and not loop.first %}
\
{% endif %}
{% if loop.first %}
{% filter indent(2, first=True) -%}
{%- if loop.first -%}"{%- endif -%}{{ branch }}{%- if not loop.last -%}:{%- endif %}
{%- endfilter %}
{% else %}
{{ branch}}{%- if not loop.last -%}:{%- endif %}
{% endif %}
{%- endfor %}" /mnt/unionfs
"{{ mergerfs_mount_branches }}" /mnt/unionfs
mergerfs_mount_stop_command: /bin/fusermount3 -uz /mnt/unionfs
15 changes: 15 additions & 0 deletions roles/unionfs/tasks/subtasks/mergerfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@
mode: "0644"
force: "{{ mergerfs_override_service }}"

- name: "MergerFS | Create '/srv/scripts' directory"
ansible.builtin.file:
path: "/srv/scripts"
state: directory
owner: "{{ user.name }}"
group: "{{ user.name }}"
mode: "0775"

- name: "MergerFS | Import 'mergerfs.sh'"
ansible.builtin.template:
src: mergerfs.sh.j2
dest: /srv/scripts/mergerfs.sh
mode: "0755"
force: "{{ mergerfs_override_service }}"

- name: "MergerFS | Systemd reload daemon"
ansible.builtin.systemd_service:
daemon_reload: true
Expand Down
2 changes: 1 addition & 1 deletion roles/unionfs/templates/mergerfs.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ After={{ mergerfs_mount_service_after }}
[Service]
Type=forking
GuessMainPID=no
ExecStart={{ mergerfs_mount_start_command }}
ExecStart=/srv/scripts/mergerfs.sh
ExecStop={{ mergerfs_mount_stop_command }}

[Install]
Expand Down
3 changes: 3 additions & 0 deletions roles/unionfs/templates/mergerfs.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

{{ mergerfs_mount_start_command }}

0 comments on commit 22bd09f

Please sign in to comment.