1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00
awx/lib/main/tasks.py
2013-03-23 18:43:11 -04:00

36 lines
1.3 KiB
Python

# (c) 2013, AnsibleWorks
#
# This file is part of Ansible Commander
#
# Ansible Commander is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible Commander is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible Commander. If not, see <http://www.gnu.org/licenses/>.
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!