feat: add JuiceFS service deployment and configuration
Some checks failed
Ansible Lint Check / check-ansible (push) Failing after 17s
Nix Format Check / check-format (push) Successful in 55s
Python Lint Check / check-python (push) Failing after 13s

This commit is contained in:
Menno van Leeuwen 2025-03-13 23:23:16 +01:00
parent e45bc5eb5a
commit e1d1125bdc
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
2 changed files with 115 additions and 0 deletions

View File

@ -11,6 +11,9 @@
- name: Include ZFS tasks
ansible.builtin.include_tasks: zfs.yml
- name: Include JuiceFS tasks
ansible.builtin.include_tasks: juicefs.yml
- name: Check if datapool exists
ansible.builtin.command: zpool list datapool
register: datapool_check

View File

@ -0,0 +1,112 @@
- name: Check if JuiceFS is already installed
ansible.builtin.command: which juicefs
register: juicefs_check
ignore_errors: true
changed_when: false
- name: Install JuiceFS using the automatic installer
ansible.builtin.shell: curl -sSL https://d.juicefs.com/install | sh -
args:
warn: false # Suppress warnings about using shell/curl
register: juicefs_installation
when: juicefs_check.rc != 0
become: true
- name: Verify JuiceFS installation
ansible.builtin.command: juicefs version
register: juicefs_version
changed_when: false
when: juicefs_check.rc != 0 or juicefs_installation.changed
- name: Create mount directory
ansible.builtin.file:
path: /mnt/object_storage
state: directory
mode: '0755'
become: true
- name: Create cache directory
ansible.builtin.file:
path: /var/jfsCache
state: directory
mode: '0755'
become: true
- name: Check if JuiceFS is already formatted
ansible.builtin.stat:
path: /mnt/juicefs-metadata.sqlite
register: metadata_file
- name: Set JuiceFS facts
ansible.builtin.set_fact:
hetzner_access_key: "{{ lookup('community.general.onepassword', 'mfk2qgnaplgtk6xmfc3r6w6neq', vault='j7nmhqlsjmp2r6umly5t75hzb4', field='AWS_ACCESS_KEY_ID') }}"
hetzner_secret_key: "{{ lookup('community.general.onepassword', 'mfk2qgnaplgtk6xmfc3r6w6neq', vault='j7nmhqlsjmp2r6umly5t75hzb4', field='AWS_SECRET_ACCESS_KEY') }}"
- name: Format JuiceFS volume
ansible.builtin.command: >
juicefs format
--storage s3
--capacity=5000
--bucket https://mvl-sh.hel1.your-objectstorage.com
--access-key {{ hetzner_access_key }}
--secret-key {{ hetzner_secret_key }}
--trash-days=7
--dir-stats
--hash-prefix
sqlite3:///mnt/juicefs-metadata.sqlite myjfs
become: true
when: not metadata_file.stat.exists
- name: Create JuiceFS systemd service file
ansible.builtin.template:
src: juicefs.service.j2
dest: /etc/systemd/system/juicefs.service
owner: root
group: root
mode: '0644'
become: true
- name: Create systemd service file content
ansible.builtin.copy:
content: |
[Unit]
Description=JuiceFS
After=network.target
Before=docker.service
[Service]
Type=simple
ExecStart=/usr/local/bin/juicefs mount sqlite3:///mnt/juicefs-metadata.sqlite /mnt/object_storage --cache-dir=/var/jfsCache --buffer-size=8192 --prefetch=4 --cache-size=204800 --writeback --attr-cache=1 --entry-cache=1 --open-cache=1
Restart=on-failure
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/juicefs.service
owner: root
group: root
mode: '0644'
become: true
- name: Reload systemd daemon
ansible.builtin.systemd:
daemon_reload: true
become: true
- name: Enable and start JuiceFS service
ansible.builtin.systemd:
name: juicefs.service
enabled: true
state: started
become: true
- name: Check if JuiceFS is mounted
ansible.builtin.shell: df -h | grep /mnt/object_storage
become: true
register: mount_check
ignore_errors: true
changed_when: false
- name: Display mount status
ansible.builtin.debug:
msg: "JuiceFS is successfully mounted at /mnt/object_storage"
when: mount_check.rc == 0