Hello everyone,

Greetings!

- name: "Add disk for VM: {{ vm_name }}"

  community.vmware.vmware_guest_disk:

    hostname: hostname

    username: username

    password: password

    validate_certs: false

    datacenter: XYZ

    moid: '{{ vm_info.id }}'

    disk:

      - size_mb: 5000

        type: thick

        datastore: XYZ

        state: present

        controller_type: IDE

        controller_number: 0

        unit_number: 1

  delegate_to: "{{ delegation_host }}"
I am executing an Ansible playbook that adds a disk to the VMware virtual 
machine when it is powered off. This is because disk additions are not 
possible when the virtual machine is powered on. After the virtual machine 
reboots, I include a task to create a partition and extend the volume group.

When the VM reboots, sometimes the newly added disk is /dev/sdb and 
sometimes /dev/sda. When it is created with /dev/sdb everything works fine, 
but when the device letter drift happens i.e., when the newly created disk 
is created with /dev/sda we receive error /dev/sdb in use while create 
partition task . 

- name: "Create partition"

  community.general.parted:

    device: /dev/sdb

    number: 1

    label: msdos

    state: present

    part_start: 0%

    part_end: 100%
This is obvious as newly created disk assigned with device/dev/sda and 
/dev/sdb is pointing to current os file system. 

- name: "Extend volume group on top of /dev/sdb"

  community.general.lvg:

    vg: volgrp

    pvs: /dev/sda2,/dev/sdb1
Also i receive the error " Device /dev/sda2 not found " when device letter 
drift happens.

Question 1: Is there any possibility to assign newly added disk with 
/dev/sdb only ? So that task 2 and task 3 execute perfectly.
Question 2: When creating partition device parameter is required , how can 
we add device value to newly added disk only ( ex: if the newly added disk 
is assigned /dev/sdb it should take the same value in create partition 
device parameter) 
Question3: how can we add value in pvs from above fetched info ? 

I have gone through docs that when the VM reboots there is no guarantee 
that /dev/sd* will be created. * may vary when vm reboots. How to solve 
this with ansible ?

Hope someone will solve this! 

Thank you!
HSK

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e78264cb-0b87-49d7-b76f-93785e24f8f4n%40googlegroups.com.

Reply via email to