Create Logical volumes with lvm.yml in all nodes according to following requirements. ---------------------------------------------------------------------------------------- * Create a new Logical volume named as 'data' * LV should be the member of 'research' Volume Group * LV size should be 1500M * It should be formatted with ext4 file-system. --> If Volume Group does not exist then it should print the message "VG Not found" --> If the VG can not accommodate 1500M size then it should print "LV Can not be created with following size", then the LV should be created with 800M of size. --> Do not perform any mounting for this LV.
正解:
Solution as: # pwd /home/admin/ansible # vim lvm.yml --- - name: hosts: all ignore_errors: yes tasks: - name: lvol: lv: data vg: research size: "1500" - debug: msg: "VG Not found" when: ansible_lvm.vgs.research is not defined - debug: msg: "LV Can not be created with following size" when: ansible_lvm.vgs.research.size_g < "1.5" - name: lvol: lv: data vg: research size: "800" when: ansible_lvm.vgs.research.size_g < "1.5" - name: filesystem: fstype: ext4 dev: /dev/research/data :wq! # ansible-playbook lvm.yml --syntax-check # ansible-playbook lvm.yml