softplayer-ansible/playbooks/systems/k3s-bootstrap/tasks/volumes.yaml

34 lines
964 B
YAML

# -----------------------------------
# -- Configure volumes
# -----------------------------------
- name: Configure volumes
when: volumes is defined
block:
- name: Ensure volumes exist
become: true
community.general.parted:
device: "{{ item.device }}"
unit: KiB
loop: "{{ volumes }}"
- name: Create a directory if it does not exist
become: true
ansible.builtin.file:
path: "{{ item.dir }}"
state: directory
mode: '0755'
loop: "{{ volumes }}"
- name: Create a ext4 filesystem
become: true
community.general.filesystem:
fstype: "{{ item.fstype }}"
dev: "{{ item.device }}"
loop: "{{ volumes }}"
- name: Remount volume to another location
become: true
ansible.posix.mount:
path: "{{ item.dir }}"
src: "{{ item.device }}"
state: mounted
fstype: "{{ item.fstype }}"
loop: "{{ volumes }}"