I'm trying to use Ansible to create a playbook that includes a different playbooks as one of its' tasks.
To clarify, the playbook is meant to deploy Linux servers, and one of the steps is to clone a git repository.
When importing it (I tried using import_tasks
, include_tasks
, import_playbook
, and include_playbook
), Ansible returns the following error:
ERROR! conflicting action statements: hosts, gather_facts
Sure enough, when I edit the git playbook and remote the hosts
statement, the import works without issue.
However, the git cloning is also meant to run independently (to keep said repository in sync), and therefore must include the hosts
directive as well.
What I'm essentially looking for is a way to import a playbook's tasks, with the importing playbook's hosts instead of the imported playbook's hosts.
I can simply remove the hosts directive from the git playbook and call it via some other playbook, but I'm wondering if there's a simpler way, or perhaps I'm just missing the right syntax.
Is there a simple way to import a playbook's tasks without its' hosts?
Thanks!