What is the best strategy for running an ansible playbook within an ansible playbook? I have playbook that I've been hacking on for a year and it works OK, but I know it's not great, part of it runs ansible on the target machine with a "command" task.  Because of that, I don't see the output of this task in my ansible playbook.  

I need to run this play in the middle of the playbook because it is dependent on a prior task and a subsequent task depends on it (otherwise I'd break it up differently) 

I'd like to be able to see the output of all my plays, is there a better way to branch off plays in the middle of a play.  

For instance: given a playbook running on HOST_A and HOST_B at TASK 3, suspend running plays, run next plays on HOST_C and HOST_D then HOST_E and HOST_F? 

- name: update other machines
  command: "/usr/bin/ansible-playbook /etc/ansible/playbooks/other-machines.yml -e 'ansible_user={{ item.ansible_user }}' -l {{ item.ansible_hostname }}"
  with_items: "{{ other_machine_connections }}"
If I've understood your problem correctly:


the ansible shell command in the middle could be converted to a simple playbook using the command task - let's call this middle.yml
your existing playbook could then directly import this middle.yml play (or even a more complex playbook).  In Ansible 2.4+, you would use import_playbook, specifically import_playbook: middle.yml, or in earlier versions, just include: middle.yml.


This processes the whole middle.yml playbook as if it was part of the main playbook - you have all the features of Ansible plays (hosts etc) and the output appears as part of main playbook.

This answer may need updating depending on your response to my comment above.