Is it acceptable to call 'ansible-playbook' from an Ansible role?

I would like some other’s thoughts on calling ‘ansible-playbook’ from within an Ansible role - essentially calling Ansible from Ansible. It certainly looks strange…but it works. And I’m not sure of another way to go about it in my specific scenario. Is this “OK” to do? Or a big no-no? If its a no, then what’s the reasoning why? Is there a better way to achieve what I am trying to do?

Here’s my scenario…

I want to use an existing collection of roles (not a single role), that has its own playbook provided, and automate downloading and using it with Ansible (and do other things in addition to that). Because it is a collection of roles with a playbook I need to call, I cannot use “include_role.”

More specifically, I want to automate the creation of a kubernetes cluster using Kubespray (https://github.com/kubernetes-incubator/kubespray). Instead of instructing the user to manually download kubespray, manually unzip it, and manually run it, then finally run my role that does additional things, I’ve automated all of it via Ansible. Here’s what I’m doing:

`

#In this shell command, ‘cluster.yml’ is the playbook provided by kubespray

  • name: Creating kubernetes cluster with Kubespray.
    shell: “ansible-playbook -i ~/.ansible/kubespray/inventory/hosts.ini ~/.ansible/kubespray/cluster.yml”
    register: ansible_output

Other things

Other things

etc, etc

`

Is this an acceptable approach? Certainly calling ansible from ansible seems odd, but it works.

I would consider it unusual, but it should work fine. Assuming there are no

expectations that the outer and inner ansible-playbook invocations are sharing

internal data or state.

See https://image.slidesharecdn.com/moretipsntricks-161011152406/95/more-tips-n-tricks-24-638.jpg?cb=1476199481

(slide 24 of https://www.slideshare.net/bcoca/more-tips-n-tricks)