274
274
- name: ANSIBLE_NETWORK_SINGLE_USER_MODE
275
275
vars:
276
276
- name: ansible_network_single_user_mode
277
+ platform_type:
278
+ description:
279
+ - Set type of platform.
280
+ env:
281
+ - name: ANSIBLE_PLATFORM_TYPE
282
+ vars:
283
+ - name: ansible_platform_type
277
284
"""
278
285
279
286
from functools import wraps
@@ -362,13 +369,29 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
362
369
self ._single_user_mode = False
363
370
364
371
if self ._network_os :
365
- self ._terminal = terminal_loader .get (self ._network_os , self )
372
+ self .load_platform_plugins (self ._network_os )
373
+
374
+ def load_platform_plugins (self , platform_type = None ):
375
+ platform_type = platform_type or self .get_option ("platform_type" )
376
+
377
+ if platform_type :
378
+ self ._terminal = terminal_loader .get (platform_type , self )
366
379
if not self ._terminal :
367
380
raise AnsibleConnectionFailure (
368
- "network os %s is not supported" % self ._network_os
381
+ "network os %s is not supported" % platform_type
382
+ )
383
+ else :
384
+ self .queue_message (
385
+ "vvvv" ,
386
+ "loaded terminal plugin %s from path %s for network_os %s"
387
+ % (
388
+ self .terminal ._load_name ,
389
+ self .terminal ._original_path ,
390
+ platform_type ,
391
+ ),
369
392
)
370
393
371
- self .cliconf = cliconf_loader .get (self . _network_os , self )
394
+ self .cliconf = cliconf_loader .get (platform_type , self )
372
395
if self .cliconf :
373
396
self ._sub_plugin = {
374
397
"type" : "cliconf" ,
@@ -381,21 +404,20 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
381
404
% (
382
405
self .cliconf ._load_name ,
383
406
self .cliconf ._original_path ,
384
- self . _network_os ,
407
+ platform_type ,
385
408
),
386
409
)
387
410
else :
388
411
self .queue_message (
389
412
"vvvv" ,
390
- "unable to load cliconf for network_os %s"
391
- % self ._network_os ,
413
+ "unable to load cliconf for network_os %s" % platform_type ,
392
414
)
393
415
else :
394
416
raise AnsibleConnectionFailure (
395
417
"Unable to automatically determine host network os. Please "
396
- "manually configure ansible_network_os value for this host"
418
+ "manually configure platform_type value for this host"
397
419
)
398
- self .queue_message ("log" , "network_os is set to %s" % self . _network_os )
420
+ self .queue_message ("log" , "platform_type is set to %s" % platform_type )
399
421
400
422
@property
401
423
def ssh_type_conn (self ):
@@ -612,11 +634,6 @@ def _connect(self):
612
634
if self ._ssh_type == "paramiko" :
613
635
self ._ssh_shell .settimeout (command_timeout )
614
636
615
- self .queue_message (
616
- "vvvv" ,
617
- "loaded terminal plugin for network_os %s" % self ._network_os ,
618
- )
619
-
620
637
terminal_initial_prompt = (
621
638
self .get_option ("terminal_initial_prompt" )
622
639
or self ._terminal .terminal_initial_prompt
0 commit comments