$ cat lvm-playbook.yml
---
 - hosts: all
   become: yes
   tasks:

   - name: Create Volume Group
     lvg:
       vg: "{{ vg_name }}"
       pvs: "{{ pvs }}"

   - name: Create Logical Volume
     lvol:
       vg: "{{ vg_name }}"
       lv: "{{ lv_name }}"
       size: "{{ lv_size }}"

  - name: Creafe File System
    filesystem:
      fstype: ext4
      dev: "/dev/{{ vg_name }}/{{ lv_name }}"

  - name: Mount Logical volume FS
    mount:
      name: "/{{ mount_name }}"
      src: "/dev/{{ vg_name }}/{{ lv_name }}"
      fstype: ext4
      state: mounted

 

$ cat inventory.ini
127.0.0.1:22222 ansible_user=gigauser pvs=/dev/sdb vg_name=vgname1 lv_name=lv_name1 lv_size=50M mount_name=vgmount

 

$ ansible-playbook -i inventory.ini lvm-playbook.yml --ask-become-pass