a )g8@sddlmZmZmZeZddlmZddlm Z ddl m Z ddl m Z ddlmZddlmZddlmZeZd gZd Zd ZGd d d eZd S))absolute_importdivisionprint_function) constants)context)paramiko)FieldAttribute)Base)Display)check_for_controlpersist PlayContext) become become_user become_pass become_method become_flags connectiondocker_extra_args delegate_toZno_log remote_user) Zansible_connection ansible_user ansible_host ansible_portZansible_docker_extra_argsZansible_ssh_hostZansible_ssh_passZansible_ssh_portZansible_ssh_userZansible_ssh_private_key_fileZansible_ssh_pipeliningZansible_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)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)isadefault)rintboolsetFcCstjddd|jSNzYPlayContext.verbosity is deprecated, use ansible.utils.display.Display.verbosity instead.gq= ףp@)versiondisplayZ deprecated_internal_verbosityselfr&A/usr/lib/python3.9/site-packages/ansible/playbook/play_context.py verbosityxs zPlayContext.verbositycCstjddd||_dSrr!)r%valuer&r&r'r(s Ncsvtt||duri}|dd|_|dd|_d|_d|_d|_||_ t j r^| nd|_ |rr||dS)NZ conn_passrr)superr __init__getpasswordr_become_pluginpromptZ success_keyconnection_lockfdrCLIARGSset_attributes_from_clir#set_attributes_from_play)r%playZ passwordsr1 __class__r&r'r,s zPlayContext.__init__cCsHtj|j|j}|D],}|r||d}|rt||||qdS)Nname)CZconfigZget_configuration_definitionsZ plugin_typeZ _load_namer-setattrZ get_option)r%pluginoptionsoptionflagr&r&r'set_attributes_from_plugins z&PlayContext.set_attributes_from_plugincCs |j|_dSN)force_handlers)r%r5r&r&r'r4sz$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)rr2r-rrBrCr#rDr$r&r&r'r3s z#PlayContext.set_attributes_from_clicCsx|}tD]$}t||d}dur t|||q |jdur`||j}|dt|t}tj } tj dD]} | |vrt|| } qqtd| ftj dD]} | |vrqqt d|||d<d| ftj d D]} | |vrqq| d kr d |d <n tj |d <d | ftj dD] } | |vr*|| r*qq*|jpX|j|d<n6t}tj dD]"}||vrrt|d||qrg}tj D]\}}|D]v}||vrq|jdurt|tr$||vr$t||||||n$||vrt||||||qqtj dD]}||vr8qPq8|jdurttj durtttj |_t|dkrtj dD]}||vrqq|jtjv}|dtjv}|r|rt|ddn,t|dddkr|r|st|dtj |jdkr$|js$|j|_|jdkrL|d|_t d|j|jdur`|j|_|jdurt|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 NZansible_delegated_varsrzansible_%s_host remote_addrzbno remote address found for delegated host %s using its name, so success depends on DNS resolutionrzansible_%s_portportZwinrmibrzansible_%s_userrr executablerrZinventory_hostnamelocalzThe "%s" connection plugin has an improperly configured remote target value, forcing "inventory_hostname" templated value instead of the string)copyTASK_ATTRIBUTE_OVERRIDESgetattrr:rtemplater-dictr9ZDEFAULT_TRANSPORTMAGIC_VARIABLE_MAPPINGr"debugZDEFAULT_REMOTE_PORTritems isinstanceappendrFrlenrEZ LOCALHOSTrconnection_userZwarningZ check_modediff)r%Ztask variablesZtemplarZnew_infoattrZattr_valZdelegated_host_nameZdelegated_varsZdelegated_transportZ transport_varZ address_varZport_varZuser_varZexe_varZattrs_consideredZvariable_namesZ variable_nameZbecome_pass_nameZconnection_typeZremote_addr_localZinv_hostname_localr&r&r'set_task_and_variable_overrides                        z*PlayContext.set_task_and_variable_overridecCs ||_dSr@)r/)r%r;r&r&r'set_become_pluginKszPlayContext.set_become_pluginc CsltjD]\\}}zs