Initial commit
This commit is contained in:
43
roles/filesystems/tasks/main.yml
Normal file
43
roles/filesystems/tasks/main.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
- name: Ensure mount points exist when create_dir is true
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
owner: "{{ item.owner | default('root') }}"
|
||||
group: "{{ item.group | default('root') }}"
|
||||
mode: "{{ item.mode | default('0755') }}"
|
||||
loop: "{{ mounts | default([]) }}"
|
||||
become: true
|
||||
when: item.create_dir | default(false) | bool
|
||||
|
||||
- name: Verify mount points exist
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item.path }}"
|
||||
register: filesystems_mounts_stat
|
||||
changed_when: false
|
||||
loop: "{{ mounts | default([]) }}"
|
||||
|
||||
- name: Assert mount points exist
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (item.stat.exists | default(false))
|
||||
fail_msg: "Mount point {{ item.item.path }} does not exist"
|
||||
loop: "{{ filesystems_mounts_stat.results }}"
|
||||
|
||||
- name: Manage fstab entries and mount
|
||||
ansible.posix.mount:
|
||||
path: "{{ item.path }}"
|
||||
src: "{{ item.src }}"
|
||||
fstype: "{{ item.fstype }}"
|
||||
opts: "{{ item.opts | default('defaults') }}"
|
||||
state: "{{ item.state | default('mounted') }}"
|
||||
backup: true
|
||||
loop: "{{ mounts | default([]) }}"
|
||||
become: true
|
||||
|
||||
- name: Ensure directories exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: "{{ item.mode | default('0755') }}"
|
||||
loop: "{{ directories | default([]) }}"
|
||||
Reference in New Issue
Block a user