2

I cannot extend an LVM logical volume with ansible lvol module This is an excerpt from my playbook:

- name: Create lv (lvcreate)
  become: true
  lvol:
    vg: "{{item.vg_name}} "
    lv: "{{item.lv_name}} "
    force: yes
    size: "{{ item.size | default('+100%FREE') }}"
    resizefs: yes
  ignore_errors: yes
  loop: "{{ volumes }}"

And this is the volumes definition:

volumes:
  - vg_name: probavg
    pv_name: /dev/sdb,/dev/sdc
    lv_name: lv1
    mount_point: /fs1
    fstype: xfs

I get this error message:

TASK [Create lv (lvcreate)] ************************************************************************************************************************************************************** Friday 30 July 2021 14:26:26 +0200 (0:00:01.344) 0:00:01.577 *********** failed: [teszt29] (item={u'size': u'+100%FREE', u'mount_point': u'/fs1', u'vg_name': u'probavg', u'lv_name': u'lv1', u'pv_name': u'/dev/sdb,/dev/sdc', u'fstype': u'xfs'}) => {"ansible_loop_var": "item", "changed": false, "err": " Logical Volume "lv1" already exists in volume group "probavg"\n", "item": {"fstype": "xfs", "lv_name": "lv1", "mount_point": "/fs1", "pv_name": "/dev/sdb,/dev/sdc", "size": "+100%FREE", "vg_name": "probavg"}, "msg": "Creating logical volume 'lv1 ' failed", "rc": 5} ...ignoring

Of course it does exist; I want to extend it. (The vg has already been extended with /dev/sdc) Can anybody help?

My ansible version is 2.8.5

1 Answer 1

3

You have spaces in the values of your lv and vg names:

    vg: "{{item.vg_name}} "
    lv: "{{item.lv_name}} "
                         ^- here

Remove them.

    vg: "{{item.vg_name}}"
    lv: "{{item.lv_name}}"

Ansible might think "oh, 'lv1 ' doesn't exist yet, I only see 'lv1'" and tries to create it.

1
  • Wow! How on earth could that space get there?! Dont know, but this was the problem. Thanks Gerald!
    – Imre
    Jul 31, 2021 at 20:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .