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
|
- name: Install JuiceFS using the automatic installer
|
||||||
ansible.builtin.shell: curl -sSL https://d.juicefs.com/install | sh -
|
ansible.builtin.shell: curl -sSL https://d.juicefs.com/install | sh -
|
||||||
args:
|
|
||||||
warn: false # Suppress warnings about using shell/curl
|
|
||||||
register: juicefs_installation
|
register: juicefs_installation
|
||||||
when: juicefs_check.rc != 0
|
when: juicefs_check.rc != 0
|
||||||
become: true
|
become: true
|
||||||
@ -40,9 +38,6 @@
|
|||||||
}}"
|
}}"
|
||||||
redis_password: "{{ lookup('community.general.onepassword', '4cioblm633bdkl6put35lk6ql4', vault='j7nmhqlsjmp2r6umly5t75hzb4', field='password') }}"
|
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
|
- name: Create JuiceFS systemd service file
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: templates/juicefs.service.j2
|
src: templates/juicefs.service.j2
|
||||||
@ -57,6 +52,9 @@
|
|||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
- name: Include JuiceFS Redis tasks
|
||||||
|
ansible.builtin.include_tasks: services/redis/redis.yml
|
||||||
|
|
||||||
- name: Enable and start JuiceFS service
|
- name: Enable and start JuiceFS service
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: juicefs.service
|
name: juicefs.service
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
- name: Set Redis facts
|
- name: Set Redis facts
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
redis_service_dir: "{{ ansible_env.HOME }}/services/juicefs-redis"
|
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') }}"
|
redis_password: "{{ lookup('community.general.onepassword', '4cioblm633bdkl6put35lk6ql4', vault='j7nmhqlsjmp2r6umly5t75hzb4', field='password') }}"
|
||||||
|
|
||||||
- name: Create Redis service directory
|
- name: Create Redis service directory
|
||||||
@ -13,12 +12,6 @@
|
|||||||
state: directory
|
state: directory
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
- name: Create Redis data directory
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: "{{ redis_data_dir }}"
|
|
||||||
state: directory
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Deploy Redis docker-compose.yml
|
- name: Deploy Redis docker-compose.yml
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: docker-compose.yml.j2
|
src: docker-compose.yml.j2
|
||||||
@ -28,6 +21,11 @@
|
|||||||
vars:
|
vars:
|
||||||
REDIS_PASSWORD: "{{ redis_password }}"
|
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
|
- name: Stop juicefs.service to umount JuiceFS
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: juicefs.service
|
name: juicefs.service
|
||||||
@ -35,7 +33,7 @@
|
|||||||
enabled: false
|
enabled: false
|
||||||
register: juicefs_stop
|
register: juicefs_stop
|
||||||
changed_when: juicefs_stop.changed
|
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
|
- name: List containers that are running
|
||||||
ansible.builtin.command: docker ps -q
|
ansible.builtin.command: docker ps -q
|
||||||
@ -69,6 +67,7 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
register: juicefs_start
|
register: juicefs_start
|
||||||
changed_when: juicefs_start.changed
|
changed_when: juicefs_start.changed
|
||||||
|
when: juicefs_service_stat.stat.exists
|
||||||
|
|
||||||
- name: Restart containers that were stopped
|
- name: Restart containers that were stopped
|
||||||
ansible.builtin.command: docker start {{ item }}
|
ansible.builtin.command: docker start {{ item }}
|
||||||
|
Reference in New Issue
Block a user