0

https://serverfault.com/questions/1078120/add-new-disk-to-lvm-group-using-ansible-module

我发布了上述问题,但不确定它是否在正确的位置,所以在这里发布交叉。

团队,有 lvol 模块,但我很难找到将新设备添加到现有 VG 组的方法。所以我采取了替代路线来使用 shell 模块并运行 RAW 命令。但是有没有办法可以使用ansible实现相同的目标?下面是我的代码,它为 4 个步骤运行 4 个任务,它们都工作正常。我只需要等效或更好的 ansible 方法。我知道我可以使用 LIST 参数并将其设为单个任务,但我想在输出中唯一地显示每个任务,以便在观察到失败时。我可以看到它失败的地方。

变量.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 }}"
4

0 回答 0