*lvg 模組

  1. lvg 模組可管理邏輯卷冊組 (volume group),查看 lvg 模組的範例。
    [deyu1@kvm19 ansible]$ ansible-doc lvg | grep ^EX -A6
    - name: Create a volume group on top of /dev/sda1 with physical extent size = 32MB
        vg: vg.services
        pvs: /dev/sda1
        pesize: 32
  2. partvg.yml 腳本新增產生 vg fieldwork 的任務。
    [deyu1@kvm19 ansible]$ vim partvg.yml
    [deyu1@kvm19 ansible]$ cat partvg.yml
    - hosts: dev
      - name: Create a new primary partition for LVM
          device: /dev/vda
          number: 3
          flags: [ lvm ]
          state: present
          part_start: 3994624KiB
      - name: Create VG
          vg: fieldwork
          pvs: /dev/vda3
          pesize: 2
  3. ansible-playbook 執行 partvg.yml 腳本,成功產生 fieldwork 邏輯卷冊組,其中警告訊息 pesize 欄位格式是字串,建議數字 2 用引號括起來。
    [deyu1@kvm19 ansible]$ ansible-playbook partvg.yml 
    PLAY [dev] *********************************************************************
    TASK [Gathering Facts] *********************************************************
    ok: [kvm11]
    TASK [Create a new primary partition for LVM] **********************************
    ok: [kvm11]
    TASK [Create VG] ***************************************************************
     [WARNING]: The value 2 (type int) in a string field was converted to '2' (type
    string). If this does not look like what you expect, quote the entire value to
    ensure it does not change.
    changed: [kvm11]
    PLAY RECAP *********************************************************************
    kvm11 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0