Create Lower size LV. If Volume Group has less space.

29 views
Skip to first unread message

Aris Aguirre

unread,
Jan 28, 2021, 2:49:36 PM1/28/21
to Ansible Project
I have a playbook below. But it only works on the nodes that has 800G (SDB) or the Volume Group has 800G free space. I am expecting that i Volume Group(vgaris) exist and only has 300G, it will still create 100G of lvaris.
--------------------------------------------------------------------------------
---
- hosts: dev
  name:
  become: yes
  vars:
    - lvname: lvaris
    - vgname: vgaris
  tasks:

  - name: Create Parted
    parted:
       device: /dev/sdb
       number: 1
       state: present


  - name: Create VG
    lvg:
      pvs: /dev/sdb1
      vg: "{{ vgname }}"
      state: present

  - name: Create LV 600G
    lvol:
      vg: "{{ vgname }}"
      lv: "{{ lvname }}"
      state: present
      size: 600G

  - name: Format to XFS
    filesystem:
       dev: /dev/{{ vgname }}/{{ lvname }}
       fstype: xfs

  - name: Add fstab and mount
    mount:
       path: /tmp/aaa
       src: /dev/{{ vgname }}/{{ lvname }}
       state: mounted
       fstype: xfs

-------------------------------------------------------------------------

Dick Visser

unread,
Jan 28, 2021, 3:55:11 PM1/28/21
to ansible...@googlegroups.com
On Thu, 28 Jan 2021 at 20:49, Aris Aguirre <aris...@gmail.com> wrote:
>
> I have a playbook below. But it only works on the nodes that has 800G (SDB) or the Volume Group has 800G free space. I am expecting that i Volume Group(vgaris) exist and only has 300G, it will still create 100G of lvaris.

Where does your expectation come from?
Because your lvol task has an explicit size parameter.
And the docs on
https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#parameter-size
mention no defaults.

If you need anything 'clever' you'd have to add that yourself to the playbook.
This usually is done by registering the output from one task, and
using that in the subsequent task(s) - with any
manipulation/transformation of it in between of course.
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6e2dbbe0-033e-4426-9a4c-2ca010a21558n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Aris Aguirre

unread,
Jan 28, 2021, 5:27:43 PM1/28/21
to Ansible Project
Lets put it this way. If the vgaris has 80G, it will just create the lvaris 60G with no problem. But if the vgaris has only 50G, then it cant create the 60G but will create a 40G lvaris.
Thanks

Dick Visser

unread,
Jan 29, 2021, 1:56:00 AM1/29/21
to ansible...@googlegroups.com
Is this an observation or a question?


--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Aris Aguirre

unread,
Jan 29, 2021, 11:12:22 AM1/29/21
to ansible...@googlegroups.com
Just an observation, I fixed it via block and rescue.

You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/EHTyXUI1AKM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwMNrFq%3DBatNck0KjEQx64N1Ctg5uekAieksbsWwnS_f7w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages