Registered variables can't persists across different plays when the second playbook runs on another host than first playbook. Look at this below solution.
Solution: Store the required variable in a dummy host and refer that variable in another play through dummy host. Example is given below. https://serverfault.com/questions/962040/sharing-ansible-variable-between-plays Thanks, Ram On Sun, Mar 21, 2021, 19:50 danish09 <[email protected]> wrote: > Thanks > > On Sunday, 21 March 2021 at 11:50:11 UTC danish09 wrote: > >> Hi, >> >> My goal is to implement 2 separate playbooks from the root main.yml, >> however, I would like to execute the 2nd playbook only when the 1st gives a >> return code of 0. >> >> --- >> - hosts: all >> >> - import_playbook: sftp.yml >> >> - import_playbook: reboot.yml >> >> >> --- >> - hosts: sftp01 >> >> tasks: >> - name: create file >> shell: touch /home/xxxxxxxxx/sftp_now >> >> ---- >> - hosts: remote >> >> tasks: >> >> - name: rebooting the remote test box >> reboot: >> test_command: whoami >> become: true >> > -- > 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/9bbdba5d-3271-4612-a8ed-631cf4ff7d75n%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/9bbdba5d-3271-4612-a8ed-631cf4ff7d75n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CAPb_6RkVVc5duUr%3Dkkj1gGecAyUDXAW63g%3D3PFAHFOEis3LCxw%40mail.gmail.com.
