Score:0

Add new disk to LVM group using ansible module

gr flag

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 }}"
Score:0
cn flag

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.