diff --git a/resources/playbook/roles/bibigrid/tasks/020-disk-server-automount.yml b/resources/playbook/roles/bibigrid/tasks/020-disk-server-automount.yml new file mode 100644 index 00000000..b803d003 --- /dev/null +++ b/resources/playbook/roles/bibigrid/tasks/020-disk-server-automount.yml @@ -0,0 +1,32 @@ +- block: + - name: Make sure disks are available + failed_when: false + filesystem: + fstype: ext4 + dev: "{{ item.device }}" + force: false + state: present + + - name: Get the filesystem type of the device using lsblk + command: "lsblk -no FSTYPE {{ item.device }}" + register: filesystem_type + changed_when: false + + - name: Log the filesystem type + debug: + msg: "Filesystem type is {{ filesystem_type.stdout }}" + + - name: Create mount folders if they don't exist + file: + path: "/vol/{{ item.name }}" + state: directory + mode: '0755' + owner: root + group: '{{ ansible_distribution | lower }}' + + - name: Mount disks + mount: + path: "/vol/{{ item.name }}" + src: "{{ item.device }}" + state: mounted + fstype: "{{ filesystem_type.stdout }}" diff --git a/resources/playbook/roles/bibigrid/tasks/020-disk-server.yml b/resources/playbook/roles/bibigrid/tasks/020-disk-server.yml index de4f0049..f6dfbf85 100644 --- a/resources/playbook/roles/bibigrid/tasks/020-disk-server.yml +++ b/resources/playbook/roles/bibigrid/tasks/020-disk-server.yml @@ -17,31 +17,7 @@ - "{{ master.disks }}" when: master.disks is defined -- when: volumes is defined and auto_mount - block: - - name: Make sure disks are available - failed_when: false - filesystem: - fstype: ext4 - dev: "{{ item.device }}" - force: false - state: present - with_items: "{{ volumes }}" - - - name: Create mount folders if they don't exist - failed_when: false - file: - path: "/{{ item.name }}" - state: directory - mode: '0755' - owner: root - group: '{{ ansible_distribution | lower }}' - with_items: "{{ volumes }}" - - - name: Mount disks - failed_when: false - mount: - path: "{{ item.name }}" - src: "{{ item.device }}" - state: mounted - with_items: "{{ volumes }}" +- name: Automount + when: volumes is defined and auto_mount + include_tasks: 020-disk-server-automount.yml + with_items: "{{ volumes }}" \ No newline at end of file