Hi @all,

let me explain my scenario first, before I come to my question.

We run most of our linux servers as virtual machines in VMware vSphere 
Clusters. I would like to use a playbook that takes a snapshot from a vm 
befor it runs further tasks on the target node. In case of a broken system 
after an upgrade I could revert the snapshot and I'm up and running again.

Here is a not working example playbook:
---
- hosts: localhost
  connection: local
  vars_prompt:
    - name: "vc"
      promt: "Enter Virtual Center Server FQDN"
      private: no

    - name: "vc_datacenter"
      promt: "Enter Datacenter"
      private: no

    - name: "vc_user"
      promt: "Enter username to connect to vCenter Server: Example: 
[email protected]"
      private: no

    - name: "vc_passwd"
      promt: "Enter your password"
      privat: yes

  vars:
    nested_list:
      - { folder: 'myfolder1', vm: 'vmname' }
      - { folder: 'myfolder2', vm: 'vmname2' }
      - { folder: 'myfolder1', vm: 'vmname3' }

  tasks:
    - name: snapshot operation
      vmware_guest_snapshot:
        hostname: "{{ vc }}"
        username: "{{ vc_user }}"
        password: "{{ vc_passwd }}"
        datacenter: "{{ vc_datacenter }}"
        folder: /mydatacenter/vm/"{{ item.folder }}"/
        name: "{{ item.vm }}"
        state: absent
        snapshot_name: snap1
        description: "Fuegen Sie hier Ihre Beschreibung ein"
        validate_certs: false
      delegate_to: localhost
      with_item:
        - "{{ nested_list }}"

- hosts: staging
  tasks:
    - name: run yum -y update
      yum:
        name: "*"
        state: latest

The group 'staging' in the second play contains the hosts that should be 
updated after a snapshot was taken. In the example above ansible would at 
first try to create snapshots and at second update my nodes whether the 
snapshot creation was successful or not. I have no idea how to create a 
dependency from the second play to the first one.

Do you understand what I'm trying to accomplish? Do someone have an idea on 
how to solve this?

Best regards,
Joerg

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/73b985bd-194b-4e36-83c0-c3271d79ee86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to