*lvg 模組

  1. lvg 模組可管理邏輯卷冊組 (volume group),查看 lvg 模組的範例。
    [deyu1@kvm19 ansible]$ ansible-doc lvg | grep ^EX -A6
    EXAMPLES:
    
    - name: Create a volume group on top of /dev/sda1 with physical extent size = 32MB
      community.general.lvg:
        vg: vg.services
        pvs: /dev/sda1
        pesize: 32
    
  2. partvg.yml 腳本新增產生 vg4 的任務,PE 大小是 8M。
    [deyu1@kvm19 ansible]$ vim partvg.yml
    [deyu1@kvm19 ansible]$ cat partvg.yml
    ---
    - hosts: dev
      tasks:
      - name: Create a new primary partition for LVM
        community.general.parted:
          device: /dev/vda
          number: 4
          flags: [ lvm ]
          state: present
          part_start: 3995648KiB  ##3GiB
    
      - name: Create a volume group on top of /dev/vda4
        community.general.lvg:
          vg: vg4
          pvs: /dev/vda4
          pesize: 8
    
  3. ansible-playbook 成功執行 partvg.yml 腳本。
    [deyu1@kvm19 ansible]$ ansible-playbook partvg.yml 
    
    PLAY [balancers] ****************************************************************
    
    TASK [Gathering Facts] **********************************************************
    ok: [kvm15]
    
    TASK [Create a new primary partition for LVM] ***********************************
    ok: [kvm15]
    
    TASK [Create a volume group on top of /dev/vda4] ********************************
    changed: [kvm15]
    
    PLAY RECAP **********************************************************************
    kvm15 : ok=2  changed=1  unreachable=0  failed=0  skipped=0  rescued=0  ignored=0
    
  4. 查看 kvm15 新增名為 vg4 的 VG。
    [deyu1@kvm19 ansible]$ ansible balancers -m shell -a "vgs"
    kvm15 | CHANGED | rc=0 >>
      VG       #PV #LV #SN Attr   VSize  VFree
      vg4        1   0   0 wz--n- <2.19g <2.19g
      vg_kvm15   1   2   0 wz--n-  3.41g     0