i tried to seprate another playbook and include like post_tasks but thats
not worked.
- 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
post_tasks:
- include: vmware_snapshot_revert.yaml
But its not worked because we are calling this playbook from remote node
which is not possible. so how to handle this situtation
On Wednesday, May 22, 2019 at 4:37:30 PM UTC+5:30, Kunalsing Thakur wrote:
>
> 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 [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/8061cd22-45ce-472c-9cde-176cabb2895d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.