Hello Ansible Team,

I need to run playbook on host when puppet run done on node and then it 
will immediately restore the snapshot. and again it will run puppet. can we 
pass the control to task when second task is completed it will move to 
first one



- hosts: node1, node2, node3
  vars_files:
    - /etc/ansible/inventories/group_vars/common.yaml
  serial: 1
  gather_facts: false
  any_errors_fatal: true
  tasks:
    - name: run puppet
      shell: puppet agent -tdv

- hosts: localhost
  vars_files:
    - /etc/ansible/inventories/group_vars/common.yaml
  serial: 1
  gather_facts: false
  tasks:
    - set_fact:
        vm_name: "{{ ansible_ssh_host }}"
    - name: Revert snapshot
      vmware_guest_snapshot:
        hostname: "{{ vcenter_server }}"
        username: "{{ vcenter_user }}"
        password: "{{ vcenter_pass }}"
        datacenter: "example"
        folder: "/example/vm"
        name: "{{ vm_name}}"
        state: revert
        validate_certs: False
        snapshot_name: original
      delegate_to: localhost
    - name: Set the state of a virtual machine to poweron
      vmware_guest_powerstate:
        hostname: "{{ vcenter_server }}"
        username: "{{ vcenter_user }}"
        password: "{{ vcenter_pass }}"
        validate_certs: False
        name: "{{ vm_name }}"
        state: powered-on
      delegate_to: localhost
    - name: Wait for the reboot to complete if there was a change.
      wait_for_connection:
        connect_timeout: 10
        sleep: 5
        delay: 5
        timeout: 300
    - name: checking machine up and running
      shell: uptime


-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/369a008c-1fa5-4b3f-b5ba-6b3faadecbb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to