mirror of
https://github.com/ansible/awx.git
synced 2026-02-15 18:20:00 -03:30
Work on executing launch job via celery to run ansible playbook.
This commit is contained in:
@@ -1,7 +1,18 @@
|
||||
import os
|
||||
import subprocess
|
||||
from celery import task
|
||||
from lib.main.models import *
|
||||
|
||||
@task(name='run_launch_job')
|
||||
def run_launch_job(launch_job_pk):
|
||||
launch_job = LaunchJob.objects.get(pk=launch_job_pk)
|
||||
os.environ['ACOM_INVENTORY'] = str(launch_job.inventory.pk)
|
||||
inventory_script = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'management', 'commands', 'acom_inventory.py'))
|
||||
playbook = launch_job.project.default_playbook
|
||||
cmd = ['ansible-playbook', '-i', inventory_script, '-v']
|
||||
if False: # local mode
|
||||
cmd.extend(['-c', 'local'])
|
||||
cmd.append(playbook)
|
||||
subprocess.check_call(cmd)
|
||||
# FIXME: Do stuff here!
|
||||
|
||||
Reference in New Issue
Block a user