Score:2

Cannot extend logical volume with ansible lvol module

us flag

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

Score:3
in flag

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.

us flag
Wow! How *on earth* could that space get there?! Dont know, but this was the problem. Thanks Gerald!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.