Added role misc/hdd_dir to link data directories to HDDs
- Also added task to common to create parent directorydehydrated
parent
1414df19c2
commit
c51d098426
@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
# will be linked from hdd_source_dir to hdd_target_dir
|
||||
|
||||
# domain used to determine hdd_directory_name
|
||||
hdd_directory_name: "{{ domain }}~{{ hdd_source_dir | basename }}"
|
||||
|
||||
use_hdd_directory: no
|
||||
# hdd_source_dir
|
||||
hdd_target_dir: "{{ global_hdd_directory }}/{{ hdd_directory_name }}"
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
|
||||
allow_duplicates: yes
|
@ -0,0 +1,36 @@
|
||||
---
|
||||
|
||||
- name: Link data directory to HDD if requested
|
||||
when:
|
||||
- use_hdd_directory and hdd_target_dir is defined
|
||||
block:
|
||||
|
||||
- name: Check source directory
|
||||
stat:
|
||||
path: "{{ hdd_source_dir }}"
|
||||
follow: no # to check if it is a link
|
||||
get_attributes: no
|
||||
get_checksum: no
|
||||
get_mime: no
|
||||
register: source_dir_info
|
||||
|
||||
- name: Ensure that source directory is not already used
|
||||
fail:
|
||||
msg: >-
|
||||
Source directory {{ hdd_source_dir | quote }} already used,
|
||||
please shutdown service and transfer data manually
|
||||
when:
|
||||
- source_dir_info.stat.exists and not source_dir_info.stat.islnk
|
||||
|
||||
- name: Create target directory on HDD
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ hdd_target_dir }}"
|
||||
|
||||
- name: Create link from source to target
|
||||
file:
|
||||
state: link
|
||||
src: "{{ hdd_target_dir }}"
|
||||
dest: "{{ hdd_source_dir }}"
|
||||
owner: root
|
||||
group: root
|
Loading…
Reference in New Issue