Using Ansible’s import_playbook module I was always under the impression that the module accepts no parameters and boldly stated so! However another commentor helpfully pointed out that I was wrong.
Here’s an example. The first playbook (importer_playbook.yml
):
- import_playbook: imported-playbook.yml
vars:
foo: hunter2
… simply imports a second playbook (imported_playbook.yml
):
- hosts: localhost
tasks:
- debug:
var: foo
Running the importer-playbook results in this:
> ansible-playbook importer-playbook.yml
PLAY [localhost]
********************************************
TASK [debug]
********************************************
ok: [localhost] => {
"foo": "hunter2"
}
PLAY RECAP
********************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
It’s even stated in the documentation as an example. However I did not scroll this far down. :(