0

Team, there are lvol module but I am having hard time find way to add new device to existing VG group. so I took alternate route to use shell module and running RAW commands. but is there a way I can achieve the same using ansible? below is my code that runs 4 tasks for 4 steps and they all work fine. I just need equivalent or better ansible approach. I know I can use LIST parameter and make this a single task but I want to display each task uniquely in output such that if failure is observed. I can see where it failed.

vars.yaml

item: [/dev/sdb, /dev/sde]
- name: "Extend LV Step1 :  PVCreate device {{ item }}"
  shell: |
    pvcreate "{{ item }}"

- name: "Extend LV Step2 :  Extend Volume Group {{ vg_name }} with new device {{ item }}"
  shell: |
     vgextend "{{ vg_name }}" "{{ item }}"

- name: "Extend LV Step3 : Logical Volume Extend"
  shell: |
     lvm lvextend -l +100%FREE "{{ device_prefix }}/{{ vg_name }}/{{ fs_type }}"

- name: "Extend LV Step4: resize2fs"
  shell: |
     resize2fs -p "{{ device_prefix }}/mapper/{{ vg_name }}-{{ fs_type }}"
AhmFM
  • 109
  • 3

1 Answers1

0

I believe, for LVM there is lvol module https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html (and others, like lvg).

George Shuklin
  • 226
  • 2
  • 7