1

Hello I am trying to write a role that can ensure the exitence of a disk before creating the volume group.

- name: "create a volume group if a disk exists"
  become: yes
  block:
 - name: listing of pvs
    shell: " pvs --noheadings -o pv_name"
    register: pv_name
 - name: "VG | volume group creation"
    lvg:
      vg: "{{ configure_vg['name'] }}"
      pvs: "{{ configure_vg['pvs'] | default(configure_os_pvs) }}"
    when: configure_vg['pvs'] in pv_name.stdout

briefly I need to create a volume group from an existant physical volume with ansible

exemple:

[root@rhel ~]# vgcreate LVMvgTEST /dev/sdb /dev/sdc
Volume group "LVMvgTEST" successfully created
cilzzz
  • 39
  • 1
  • 6
  • 2
    [The fine manual](https://docs.ansible.com/ansible/2.10/collections/community/general/lvg_module.html#parameter-pvs) claims it will run pvcreate if required, which is why there is [`pv_options:`](https://docs.ansible.com/ansible/2.10/collections/community/general/lvg_module.html#parameter-pv_options) for that case; is that somehow different from your use case? – mdaniel Feb 15 '22 at 16:48
  • 1
    What is wrong with your above code? Please do not reply in comments. Edit your question and make it an [mcve](/help/mcve). Thanks. – Zeitounator Feb 15 '22 at 16:49
  • i don't need to create a pv , i only need to create a volume group from an existent pv , if the pv is not present or it is already assigned to another volume group it won't be created – cilzzz Feb 16 '22 at 09:02

0 Answers0