How to nest playbooks on best practice?

I wanto to nest playbooks on best practice as a following python code.
Have any idea?

#!/usr/bin/env python

import os

configure web servers

os.system(‘ansible-playbooks -i webservers web_configure.yml’)

db_configs = [
{‘foo’:1, ‘bar’:2, ‘baz’:3}
{‘foo’:2, ‘bar’:4, ‘baz’:2}
{‘foo’:3, ‘bar’:6, ‘baz’:1}
]

for db_configs as db_config:

configure db servers

os.system(“ansible -i dbservers all -m ‘FOO=%(foo) BAR=%(bar) BAZ =%(baz)’” % db_config)

benchmark test (atacking from erb servers to db servers)

os.system(“ansible-playbooks -i webservers db_attack.yml” % db_config)

I would hope you do not attack things with playbooks and only use them for good, not evil :slight_smile:

You should really consider importing the ansible python modules into
your script rather than shelling out to ansible-playbook. Everything
will be much cleaner and happier.