sunder
sunder

Reputation: 1843

Ansible - include one playbook into another in loop

I am new to ansible and trying to figure out how can I call one playbook from another playbook in loop. I also want to consume the output back in master playbook. Not sure if it could be possible in Ansible.

Below is a stub from other programming languages -

masterplaybook.yml - from where I want to invoke auditplaybook

   for devicePair in devicePairList
        output = auditdevice.yml -e "d1=devicePair.A d2=devicePair.B"
    save/process output

auditdevice.yml playbook is using d1 and d2 as hosts on which it is performing auditing, running commands etc. It is performing audit on dynamic inventory passed as part of argument.

Is it possible to achieve above using Ansible? If yes, can someone point to any example?

Upvotes: 0

Views: 3128

Answers (1)

Vladimir Botka
Vladimir Botka

Reputation: 68124

Q: "How can I call one playbook from another playbook in the loop?"

A: It is not possible. Quoting from import_playbook

"You cannot use this action inside a play."

See the example.


FWIW. ansible-runner is able to controll playbooks withing projects similar to AWX. See example.

Upvotes: 1

Related Questions