1010from ansible_runner .exceptions import AnsibleRunnerException
1111from runner_service import configuration
1212from runner_service .cache import runner_cache , runner_stats
13- from .utils import cleanup_dir , APIResponse
13+ from .utils import APIResponse
1414from ..utils import fread
1515
1616from ..cache import event_cache
@@ -193,15 +193,6 @@ def cb_event_handler(event_data):
193193 return True
194194
195195
196- def commit_cmdline (options ):
197- cmd_file = os .path .join (configuration .settings .playbooks_root_dir ,
198- "env" , "cmdline" )
199- runtime_overrides = ' ' .join (options )
200- logger .debug ("Creating env/cmdline file: {}" .format (runtime_overrides ))
201- with open (cmd_file , "w" ) as cmdline :
202- cmdline .write (runtime_overrides )
203-
204-
205196def start_playbook (playbook_name , vars = None , filter = None , tags = None ):
206197 """ Initiate a playbook run """
207198
@@ -214,8 +205,15 @@ def start_playbook(playbook_name, vars=None, filter=None, tags=None):
214205
215206 # this should just be run_async, using 'run' hangs the root logger output
216207 # even when backgrounded
208+
209+ artifacts_dir = os .path .join (configuration .settings .playbooks_root_dir , "artifacts" )
210+ private_data_dir = os .path .join (artifacts_dir , play_uuid )
211+ os .makedirs (private_data_dir )
217212 parms = {
218- "private_data_dir" : configuration .settings .playbooks_root_dir ,
213+ "private_data_dir" : private_data_dir ,
214+ "project_dir" : os .path .join (configuration .settings .playbooks_root_dir , 'project' ),
215+ "inventory" : os .path .join (configuration .settings .playbooks_root_dir , 'inventory' ),
216+ "artifact_dir" : artifacts_dir ,
219217 "settings" : settings ,
220218 "finished_callback" : cb_playbook_finished ,
221219 "event_handler" : cb_event_handler ,
@@ -236,10 +234,6 @@ def start_playbook(playbook_name, vars=None, filter=None, tags=None):
236234 if limit_hosts :
237235 parms ['limit' ] = limit_hosts
238236
239- logger .debug ("Clearing up old env directory" )
240- cleanup_dir (os .path .join (configuration .settings .playbooks_root_dir ,
241- "env" ))
242-
243237 cmdline = []
244238 if filter .get ('check' , 'false' ).lower () == 'true' :
245239 cmdline .append ('--check' )
@@ -252,13 +246,11 @@ def start_playbook(playbook_name, vars=None, filter=None, tags=None):
252246 "{}" .format (configuration .settings .target_user ))
253247 cmdline .append ("--user {}" .format (configuration .settings .target_user ))
254248
255- if not configuration .settings .ssh_private_key .endswith ('env/ssh_key' ):
256- logger .debug ("Run the playbook with a private key override of "
257- "{}" .format (configuration .settings .ssh_private_key ))
258- cmdline .append ("--private-key {}" .format (configuration .settings .ssh_private_key ))
249+ logger .debug ("Run the playbook with a private key override of "
250+ "{}" .format (configuration .settings .ssh_private_key ))
251+ cmdline .append ("--private-key {}" .format (configuration .settings .ssh_private_key ))
259252
260- if cmdline :
261- commit_cmdline (cmdline )
253+ parms ['cmdline' ] = ' ' .join (cmdline )
262254
263255 _thread , _runner = run_async (** parms )
264256
0 commit comments