
    Vh6                    ~    d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ  e       ZdgZdZd	Z G d
 de	      Zy)    )annotations)	constants)context)FieldAttribute)Base)DisplayPlayContext)
becomebecome_userbecome_passbecome_methodbecome_flags
connectiondocker_extra_argsdelegate_tono_logremote_user)ansible_connectionansible_useransible_hostansible_portansible_docker_extra_argsansible_ssh_hostansible_ssh_passansible_ssh_portansible_ssh_useransible_ssh_private_key_fileansible_ssh_pipeliningansible_ssh_executablec                      e Zd ZdZ edej                        Z ed      Z edej                        Z
 ed      Z ed      Z edej                        Z ed      Z edej                         Z edej$                        Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z ed      Z edej6                        Z edej:                        Z ed      Z ede       Z! ede       Z" ed      Z# edd      Z$ edd      Z%d fd		Z&d
 Z'd Z(d Z)d Z*d Z+d Z, xZ-S )r	   z
    This class is used to consolidate the connection information for
    hosts in a play and child tasks, where the task may override some
    connection/authentication information.
    string)isadefault)r"   intboolsetFc                >   t         t        |           |i }|j                  dd      | _        |j                  dd      | _        d | _        d| _        d| _        || _	        t        j                  r| j                          nd| _        |r| j                  |       y y )N	conn_pass r   r   )superr	   __init__getpasswordr   _become_pluginpromptsuccess_keyconnection_lockfdr   CLIARGSset_attributes_from_cli_internal_verbosityset_attributes_from_play)selfplay	passwordsr1   	__class__s       M/home/dcms/DCMS/lib/python3.12/site-packages/ansible/playbook/play_context.pyr+   zPlayContext.__init__t   s    
 	k4)+I!k26$==;" "3 ??((*'(D$))$/     c                    t         j                  j                  |j                  |j                        }|D ]8  }|s||   j                  d      }|st        | ||j                  |             : y )Nname)Cconfigget_configuration_definitionsplugin_type
_load_namer,   setattr
get_option)r6   pluginoptionsoptionflags        r:   set_attributes_from_pluginz&PlayContext.set_attributes_from_plugin   sh     ((889K9KVM^M^_ 	AFv**62D$(9(9$(?@		Ar;   c                &    |j                   | _         y N)force_handlers)r6   r7   s     r:   r5   z$PlayContext.set_attributes_from_play   s    "11r;   c                `   t         j                  j                  dd      r!t        t         j                  d         | _        t         j                  j                  d      | _        t         j                  j                  d      | _        t         j                  j                  dd      | _        y)z
        Configures this connection information instance with data from
        options specified by the user on the command line. These have a
        lower precedence than those set on the play or host.
        timeoutFprivate_key_file	verbositystart_at_taskN)r   r2   r,   r$   rN   rO   r4   rQ   )r6   s    r:   r3   z#PlayContext.set_attributes_from_cli   sy     ??y%0wy9:DL !( 3 34F G#*??#6#6{#C  %__00$Gr;   c                   | j                         }t        D ]  }t        ||d      x}t        |||       ! |j                  ~|j                  |j                        }|j                  dt                     j                  |t                     }t        j                  }	t        j                  j                  d      D ]  }
|
|v s||
   }	 n d|	z  ft        j                  j                  d      z   D ]  }||v s n t        j                  d|z         ||d<   d|	z  ft        j                  j                  d	      z   D ]  }||v s n |	d
k(  rd|d<   nt        j                  |d<   d|	z  ft        j                  j                  d      z   D ]  }||v s||   s nn |j                  xs | j                  |d<   nOt               }t        j                  j                  d      D ]#  }||v st        |d|j                  |             % g }t        j                  j                         D ]{  \  }}|D ]q  }||v r|j                  8t!        |t              s%||v s*t        ||||          |j#                  |       L||v sQt        ||||          |j#                  |       s } t        j                  j                  d      D ]  }||v s n |j$                  .t        j                  t'        t        j                        |_        t)        |      dkD  rt        j                  j                  d      D ]  }||v s n |j*                  t        j,                  v }|j                  d      t        j,                  v }|r|rt        |dd       n/t        |dd      dk(  r|r|st        |dt        j                         |j.                  dk(  r|j0                  s|j                  |_        |j*                  dk(  r8|j                  d      |_        t        j3                  d|j.                  z         |j4                  |j4                  |_        |j6                  |j6                  |_        |S )a7  
        Sets attributes from the task if they are set, which will override
        those from the play.

        :arg task: the task object with the parameters that were set on it
        :arg variables: variables from inventory
        :arg templar: templar instance if templating variables is needed
        Nansible_delegated_varsr   zansible_%s_hostremote_addrzbno remote address found for delegated host %s
using its name, so success depends on DNS resolutionr   zansible_%s_portportwinrmib  r   zansible_%s_userr   r   
executabler   r   inventory_hostnamelocalzThe "%s" connection plugin has an improperly configured remote target value, forcing "inventory_hostname" templated value instead of the string)copyTASK_ATTRIBUTE_OVERRIDESgetattrrC   r   templater,   dictr>   DEFAULT_TRANSPORTMAGIC_VARIABLE_MAPPINGdisplaydebugDEFAULT_REMOTE_PORTr   items
isinstanceappendrU   r$   lenrT   	LOCALHOSTr   connection_userwarning
check_modediff)r6   task	variablestemplarnew_infoattrattr_valdelegated_host_namedelegated_varsdelegated_transporttransport_varaddress_varport_varuser_varexe_varattrs_consideredvariable_namesvariable_namebecome_pass_nameconnection_typeremote_addr_localinv_hostname_locals                         r:   set_task_and_variable_overridez*PlayContext.set_task_and_variable_override   s    99; - 	2D#D$55B$1	2 ' #*"2"243C3C"D&]]+CTVLPPQdfjflmN"#"5"5!"!9!9!=!=l!K  N2*8*G' !24G GIALdLdLhLhivLww E.0E   D  GZ  Z  [1D~. /1DDFIaIaIeIeflImm K~-K ''159N>2565J5JN>2 /1DDFIaIaIeIefsItt V~-.2JV 261A1A1UTEUEU~.!VN 3377E Li'HlIMM'4JKL &'&>&>&D&D&F 	2"T>!/ 
2++##/!.$7M^<[$}0MN(//5"i/HdIm,DE$++D1
2	2  !" 8 8 < <] K 	9,	
 == Q%:%:%F 5 56HM ~" $%#;#;#?#?#M 	I"n4	I %-$8$8AKK$G!%3%7%78L%MQRQ\Q\%\"$);HlG<X|T:gEO`hzHlA4G4GH ')+++3+?+?( #77#,==1E#FH OO ackcvcvw x ??&"&//H99  IIHMr;   c                    || _         y rK   )r.   )r6   rE   s     r:   set_become_pluginzPlayContext.set_become_plugin7  s
    $r;   c                    t         j                  j                         D ]+  \  }}	 d|v rt        | |      }|D ]  }||vs||||<    - y# t        $ r Y :w xY w)z
        Adds 'magic' variables relating to connections to the variable dictionary provided.
        In case users need to access from the play, this is a legacy from runner.
        r
   N)r>   r`   rd   r\   AttributeError)r6   rn   propvar_listvar_valvar_opts         r:   update_varszPlayContext.update_vars:  s|      66<<> 
	ND(	t#!$-' 5Gi/G4G-4	'*5
	 " s"   AAAA	AA)NNN).__name__
__module____qualname____doc__r   r>   DEFAULT_MODULE_COMPRESSIONmodule_compressionshellDEFAULT_EXECUTABLErW   rT   r-   DEFAULT_TIMEOUTrN   ri   DEFAULT_PRIVATE_KEY_FILErO   ANSIBLE_PIPELINING
pipelining
network_osr   r1   r
   r   r   r   DEFAULT_BECOME_EXE
become_exeDEFAULT_BECOME_FLAGSr   r/   r&   	only_tags	skip_tagsrQ   steprL   r+   rI   r5   r3   r   r   r   __classcell__)r9   s   @r:   r	   r	   B   ss    (Ha>Z>Z[x(EHa6J6JKJ !X.K(+H0A0ABG$2O%(A<V<VWFA4H4HIJ  H-J '84 '51 'F"x0M X.K X.KHa6J6JKJ!h8N8NOL)F 5#6I5#6I"x0Mfe4D $>N0<	A2H"DL%r;   N)
__future__r   ansibler   r>   r   ansible.playbook.attributer   ansible.playbook.baser   ansible.utils.displayr   ra   __all__r[   
RESET_VARSr	    r;   r:   <module>r      sH   ( # "  5 & ) ) / 
$H$ Hr;   