Added role misc/hdd_dir to link data directories to HDDs

- Also added task to common to create parent directory
dehydrated
Felix Stupp 4 years ago
parent 1414df19c2
commit c51d098426
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -38,6 +38,16 @@
vars:
ansible_become: no
- name: Create hdd data directory
file:
state: directory
path: "{{ global_hdd_directory }}"
owner: root
group: root
mode: u=rwx,g=rx,o=rx
when:
- global_hdd_directory is defined
- name: Create scripts directories
file:
path: "{{ item }}"

@ -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…
Cancel
Save