import os import sys from ansible_runner import Runner, RunnerConfig def executePlaybook(): rc = RunnerConfig( private_data_dir="/workspace" ) rc.playbook=os.environ.get('ANSIBLE_PLAYBOOK', "site.yml") rc.inventory=os.environ.get('ANSIBLE_PLAYBOOK_INVENTORY', "127.0.0.1,") if(rc.inventory=="127.0.0.1,"): rc.cmdline_args= "--limit 127.0.0.1 --connection local" rc.prepare() r = Runner(config=rc) r.run() def main(): executePlaybook() main()