o nnh8@spddlmZddlmZddlmZddlmZddlm Z ddl m Z e Z dgZ dZd ZGd dde Zd S) ) annotations) constants)context)FieldAttribute)Base)Display PlayContext) become become_user become_pass become_method become_flags connectiondocker_extra_args delegate_tono_log remote_user) ansible_connection ansible_user ansible_host ansible_portansible_docker_extra_argsansible_ssh_hostansible_ssh_passansible_ssh_portansible_ssh_useransible_ssh_private_key_fileansible_ssh_pipeliningansible_ssh_executablecseZdZdZedejdZeddZedej dZ eddZ eddZ edej dZeddZedejdZedejdZeddZeddZeddZeddZeddZeddZeddZedejdZedejdZeddZede dZ!ede dZ"eddZ#edddZ$edddZ%e&d d Z'e'j(d d Z'dfd d Z)ddZ*ddZ+ddZ,ddZ-ddZ.ddZ/Z0S)rz 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)isadefault)r intboolsetFcCstjddd|jSNzYPlayContext.verbosity is deprecated, use ansible.utils.display.Display.verbosity instead.z2.18)versiondisplay deprecated_internal_verbosityselfr-H/usr/local/lib/python3.10/dist-packages/ansible/playbook/play_context.py verbosityts zPlayContext.verbositycCstjddd||_dSr%r')r,valuer-r-r.r/|s  Ncsztt||dur i}|dd|_|dd|_d|_d|_d|_||_ t j r/| nd|_ |r;||dSdS)N conn_passr r)superr__init__getpasswordr _become_pluginprompt success_keyconnection_lockfdrCLIARGSset_attributes_from_clir*set_attributes_from_play)r,play passwordsr: __class__r-r.r4s zPlayContext.__init__cCsHtj|j|j}|D]}|r!||d}|r!t||||q dS)Nname)Cconfigget_configuration_definitions plugin_type _load_namer5setattr get_option)r,pluginoptionsoptionflagr-r-r.set_attributes_from_pluginsz&PlayContext.set_attributes_from_plugincCs |j|_dSN)force_handlers)r,r>r-r-r.r=s z$PlayContext.set_attributes_from_playcCsNtjddrttjd|_tjd|_tjd|_tjdd|_dS)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. timeoutFprivate_key_filer/ start_at_taskN)rr;r5r"rQrRr*rSr+r-r-r.r<s z#PlayContext.set_attributes_from_clicCsR|}tD]}t||d}durt|||q|jdur||j}|dt|t}tj } tj dD] } | |vrE|| } nq9d| ftj dD]} | |vrYn qQt d|||d<d| ftj d D]} | |vrxnqp| d krd |d <ntj |d <d | ftj dD] } | |vr|| rn q|jp|j|d<nt}tj dD]}||vrt|d||qg}tj D]<\}}|D]5}||vrq|jdurt|tr||vrt||||||q||vrt||||||qqtj dD] }||vrnq |jdur(tj dur(ttj |_t|dkrqtj dD] }||vr>n3q5|jtjv}|dtjv}|r[|r[t|ddnt|dddkrq|rj|sqt|dtj |jdkr|js|j|_|jdkr|d|_t d|j|jdur|j|_|jdur|j|_|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 Nansible_delegated_varsrzansible_%s_host remote_addrzbno remote address found for delegated host %s using its name, so success depends on DNS resolutionrzansible_%s_portportwinrmibrzansible_%s_userrr executabler rinventory_hostnamelocalzThe "%s" connection plugin has an improperly configured remote target value, forcing "inventory_hostname" templated value instead of the string)copyTASK_ATTRIBUTE_OVERRIDESgetattrrHrtemplater5dictrCDEFAULT_TRANSPORTMAGIC_VARIABLE_MAPPINGr(debugDEFAULT_REMOTE_PORTritems isinstanceappendrVr"lenrU LOCALHOSTrconnection_userwarning check_modediff)r,task variablestemplarnew_infoattrattr_valdelegated_host_namedelegated_varsdelegated_transport transport_var address_varport_varuser_varexe_varattrs_consideredvariable_names variable_namebecome_pass_nameconnection_typeremote_addr_localinv_hostname_localr-r-r.set_task_and_variable_overrides                    z*PlayContext.set_task_and_variable_overridecCs ||_dSrO)r7)r,rJr-r-r.set_become_pluginGs zPlayContext.set_become_pluginc CsftjD]+\}}zd|vrWqt||}|D]}||vr%|dur%|||<qWqty0YqwdS)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)rCrardr]AttributeError)r,rnpropvar_listvar_valvar_optr-r-r. update_varsJs  zPlayContext.update_vars)NNN)1__name__ __module__ __qualname____doc__rrCDEFAULT_MODULE_COMPRESSIONmodule_compressionshellDEFAULT_EXECUTABLErXrUr6DEFAULT_TIMEOUTrQriDEFAULT_PRIVATE_KEY_FILErRANSIBLE_PIPELINING pipelining network_osrr:r r r r DEFAULT_BECOME_EXE become_exeDEFAULT_BECOME_FLAGSr r8r$ only_tags skip_tagsrSsteprPpropertyr/setterr4rNr=r<rrr __classcell__r-r-r@r.rBsL                    N) __future__ransiblerrCransible.playbook.attributeransible.playbook.baseransible.utils.displayrr(__all__r\ RESET_VARSrr-r-r-r.s