From a2591313e7e2011b043431646285d4e27d5780bc Mon Sep 17 00:00:00 2001 From: Olivier Navas Date: Sat, 13 Jan 2024 20:06:17 +0100 Subject: [PATCH] Prise en compte du formatage et du montage des LV --- tasks/prepare_logical_volume.yml | 37 ++++++++++++++++++++++++++++++++ tasks/setup_vm.yml | 10 ++++----- 2 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 tasks/prepare_logical_volume.yml diff --git a/tasks/prepare_logical_volume.yml b/tasks/prepare_logical_volume.yml new file mode 100644 index 0000000..927300b --- /dev/null +++ b/tasks/prepare_logical_volume.yml @@ -0,0 +1,37 @@ + +- name: Contexte logical volume + debug: + var: _lv + +- name: Definit logical volume + lvol: + vg: "{{ _lv.vg }}" + lv: "{{ _lv.name }}" + size: "{{ _lv.size }}" + resizefs: true + delegate_to: "{{ _vm_ip }}" + +- name: Verifie que logical volume est formaté + filesystem: + fstype: xfs + dev: "/dev/{{ _lv.vg }}/{{ _lv.name }}" + delegate_to: "{{ _vm_ip }}" + when: _lv.mountpoint is defined + +- name: Verifie que mountpoint existe + file: + path: "{{ _lv.mountpoint }}" + state: directory + mode: '0755' + when: _lv.mountpoint is defined + delegate_to: "{{ _vm_ip }}" + +- name: Monte logical volume + mount: + path: "{{ _lv.mountpoint }}" + src: "/dev/{{ _lv.vg }}/{{ _lv.name }}" + fstype: xfs + state: mounted + when: _lv.mountpoint is defined + delegate_to: "{{ _vm_ip }}" + diff --git a/tasks/setup_vm.yml b/tasks/setup_vm.yml index 9c26452..b89a32a 100644 --- a/tasks/setup_vm.yml +++ b/tasks/setup_vm.yml @@ -74,12 +74,10 @@ - name: Definit logical volume - lvol: - vg: "{{ item.vg }}" - lv: "{{ item.name }}" - size: "{{ item.size }}" - resizefs: true - delegate_to: "{{ pvmt_vm_ip }}" + include_tasks: prepare_logical_volume.yml + vars: + _lv: "{{ item }}" + _vm_ip: "{{ pvmt_vm_ip }}" with_items: - "{{ pvmt_vm_lvm_volumes }}"