[ansible project] VM snapshot capture using VMware

Hi experts,

We are doing automation to update RHEL7-> RHEL8 .
Before we upgrade we take the snapshot.
The issue is whenever there is an upgrade failure we revert the server to its previous state. But it seems when we revert it the machine is in power off state…
it seems when we take automatic snapshot it happens like that… Any pointers pls

Regards
PD

Hi!

It is not clear how this is an Ansible issue. Can you provide the playbook or role code you use to accomplish this?

  • Rilindo

That's a RHEL problem. It's not an operation supported by RHEL.
Updating the critical system libraries, such as glibc and the python
on which RPM is based, and RPM itself, is likely to trip over a *lot*
of problems without quite a lot of research and debugging. From
decades of experience with Red Hat based operating systems, I
recommend very strongly against this approach.

If I may suggest, take a disk image of the old system and build a new
system, with content copied as needed to configure the new system.

Hi,

Thank you both of you for your kind suggestions.
We are using leap-upgrade tool to upgrade. In upgrade there is no issue. We have a health checkup also post upgrade.

The issue is in VMware but not sure when creating manually the “Snapshot the virtual machine memory” is set to Yes but when I am creating the snapshot through ansible automatically it is setting as No. This is something with VMware maybe…

  • Name: Create VM snapshot
    Uri:
    URL: https://api.xyz/virtualization/snapshot/snow
    User: “ {{ snapshot_user }}”
    Password: “{{ snapshot_Password }}“
    force_basic_auth: true
    Method: post
    Body_format: json
    Body: |-
    {
    “Hostname”: “{{ vm_hostname }}”,
    “Task”: “ create”,
    “Snapshot_name”: “upgrade-{{vm_hostname}} “
    }
    Status code: 202
    Register: snapshot_result

Regards
PD

Is that a space before snapshot (right where it says “Task” in the JSON request)? Was that part of the request or did you insert that by mistake when you copied it into the email?

  • Rilindo

Just as “Snapshot_name”: “upgrade-{{vm_hostname}} “ has a trailing space…

Hi Rilindo,

Thanks for your reply. That was typo error . I fixed the issue, in the REST api i need to pass memory flag which by default is false. This memory flag retains the machine power status also.

Thank you for your all support.

PD

We have these playbooks we use to create a snapshot and to revert a snapshot. The go into an ansible automation platform workflow. The esx-vars.yml has a dictionary you will need to modify for your environment. The dictionary key is a vcenter ID you create. We pass in an extravar for datacenter that provides the value of that key to look up at run time. We have an east and west vCenter and a sandbox we call “vCloud”. You will see vc_east, vc_west, vc_vcloud keys in the esx_vars.yml dictionary.

The esx-create-snapshot.yml gets info about the existing machine, powers it down, creates the snapshot, then powers it back up ONLY if it was powered on when we started (state: “{{ snapvm.instance.hw_power_status | lower }}” at line 74 comes from the guest info we get at line 31). At the bottom of esx-snapshot-create.yml we use set_stats to artifacts so they can be used downstream in the AAP workflow by ex-snapshot-revert.yml including its powered on status.

Even if you don’t use these playbooks they may help you craft your own.

Walter

(attachments)

esx-snapshot-create.yml (3.26 KB)
esx-snapshot-revert.yml (2.31 KB)
esx-vars.yml (296 Bytes)

Adding to my earlier message … we use these playbooks in a patching workflow. Snapshot, Patch, if patching fails, revert snapshot.

Walter

Thank you so much Walter that will definitely help…