refactor: streamline JuiceFS installation and Redis task inclusion in Ansible playbooks
This commit is contained in:
@ -7,8 +7,6 @@
|
||||
|
||||
- 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
|
||||
@ -40,9 +38,6 @@
|
||||
}}"
|
||||
redis_password: "{{ lookup('community.general.onepassword', '4cioblm633bdkl6put35lk6ql4', vault='j7nmhqlsjmp2r6umly5t75hzb4', field='password') }}"
|
||||
|
||||
- name: Include JuiceFS Redis tasks
|
||||
ansible.builtin.include_tasks: services/redis/redis.yml
|
||||
|
||||
- name: Create JuiceFS systemd service file
|
||||
ansible.builtin.template:
|
||||
src: templates/juicefs.service.j2
|
||||
@ -57,6 +52,9 @@
|
||||
daemon_reload: true
|
||||
become: true
|
||||
|
||||
- name: Include JuiceFS Redis tasks
|
||||
ansible.builtin.include_tasks: services/redis/redis.yml
|
||||
|
||||
- name: Enable and start JuiceFS service
|
||||
ansible.builtin.systemd:
|
||||
name: juicefs.service
|
||||
|
@ -4,7 +4,6 @@
|
||||
- name: Set Redis facts
|
||||
ansible.builtin.set_fact:
|
||||
redis_service_dir: "{{ ansible_env.HOME }}/services/juicefs-redis"
|
||||
redis_data_dir: "/mnt/object_storage/services/redis"
|
||||
redis_password: "{{ lookup('community.general.onepassword', '4cioblm633bdkl6put35lk6ql4', vault='j7nmhqlsjmp2r6umly5t75hzb4', field='password') }}"
|
||||
|
||||
- name: Create Redis service directory
|
||||
@ -13,12 +12,6 @@
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Create Redis data directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ redis_data_dir }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Deploy Redis docker-compose.yml
|
||||
ansible.builtin.template:
|
||||
src: docker-compose.yml.j2
|
||||
@ -28,6 +21,11 @@
|
||||
vars:
|
||||
REDIS_PASSWORD: "{{ redis_password }}"
|
||||
|
||||
- name: Check if juicefs.service exists
|
||||
ansible.builtin.stat:
|
||||
path: /etc/systemd/system/juicefs.service
|
||||
register: juicefs_service_stat
|
||||
|
||||
- name: Stop juicefs.service to umount JuiceFS
|
||||
ansible.builtin.systemd:
|
||||
name: juicefs.service
|
||||
@ -35,7 +33,7 @@
|
||||
enabled: false
|
||||
register: juicefs_stop
|
||||
changed_when: juicefs_stop.changed
|
||||
when: redis_compose.changed
|
||||
when: redis_compose.changed and juicefs_service_stat.stat.exists
|
||||
|
||||
- name: List containers that are running
|
||||
ansible.builtin.command: docker ps -q
|
||||
@ -69,6 +67,7 @@
|
||||
enabled: true
|
||||
register: juicefs_start
|
||||
changed_when: juicefs_start.changed
|
||||
when: juicefs_service_stat.stat.exists
|
||||
|
||||
- name: Restart containers that were stopped
|
||||
ansible.builtin.command: docker start {{ item }}
|
||||
|
Reference in New Issue
Block a user