
    VhQ                         d dl mZmZmZ eZd dl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 d dlmZ d d	lmZ d d
lmZ g dZg dZddgZ G d de      Zy)    )absolute_importdivisionprint_functionN)	constants)string_types)shlex_quoteto_text)MutableSequence)boolean)
ActionBase)connection_loader)dockerzcommunity.general.dockerzcommunity.docker.docker)podmanzansible.builtin.podmanzcontainers.podman.podmanbuildahzcontainers.podman.buildahc                   D     e Zd Zd Zd Zd Zd Zd Zd Zd fd	Z	 xZ
S )	ActionModulec                 t   |}d|v s|j                  d      r|S | j                  j                  <| j                  j	                  | j                  j                  j
                  d|      }n5| j                  j	                  | j                  j                         d|      }|r|d   dk(  r|d   dk7  r|dz  }|S )N:/files)
startswith_task_role_loaderpath_dwim_relative
_role_pathget_basedir)selfpathoriginal_paths      l/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ansible/posix/plugins/action/synchronize.py_get_absolute_pathzActionModule._get_absolute_path'   s     $;$//#.K::'<<224::3C3C3N3NPWY]^D<<224<<3K3K3MwX\]D]2.#5$r(c/ CKD    c                      dt        |d      v S )Nr   surrogate_or_strict)errorsr	   )r    hosts     r#   _host_is_ipv6_addressz"ActionModule._host_is_ipv6_address?   s    gd+@AAAr%   c                     d}|j                  d      r|S | j                  t        t        z   t        z   vr|r|d}| j                  |      r
d||d|S d|vr	||d|S d|vr||S |S )z= formats rsync rsh target, escaping ipv6 addresses if needed  zrsync://@[z]:r   )r   _remote_transportDOCKERPODMANBUILDAHr*   )r    r)   r!   useruser_prefixs        r#   _format_rsync_rsh_targetz%ActionModule._format_rsync_rsh_targetB   s     ??:&K !!&7)BBt#'*K%%d+"-tT:: d? +T488_($//Kr%   c                 t    |t         j                  vr| j                  |||      S | j                  |      }|S )Nr!   )C	LOCALHOSTr5   r$   )r    r)   r!   r3   s       r#   _process_originzActionModule._process_originY   s;    q{{"00tTBB&&D&1r%   c                    | j                   j                  }|t        j                  vs|dk7  s|t        j                  v r.|s,|r|t        j                  v rd|d<   | j	                  |||      S | j                  |      }|S )a#  
        :arg host: hostname for the path
        :arg path: file path
        :arg user: username for the transfer
        :arg port_matches_localhost_port: boolean whether the remote port
            matches the port used by localhost's sshd.  This is used in
            conjunction with seeing whether the host is localhost to know
            if we need to have the module substitute the pathname or if it
            is a different host (for instance, an ssh tunnelled port or an
            alternative ssh port to a vagrant host.)
        localT_substitute_controllerr7   )_connection	transportr8   r9   r5   r$   )r    	task_argsr)   r!   r3   port_matches_localhost_portr?   s          r#   _process_remotezActionModule._process_remotea   s     $$..	 q{{"i7&:$-H
 +tq{{/B6:	2300tTBB&&D&1r%   c                 f   d|v r|d= t        |j                               D ])  }|j                  d      s|j                  d      s'||= + t        j
                  D ]  }||d   v s|d   |   } n dv r|d   |d<   |D ].  }|j                  d      s|j                  d      s'||   ||<   0 y)z Some vars are substituted into the modules.  Have to make sure
        that those are correct for localhost when synchronize creates its own
        connection to localhost.ansible_syslog_facilityansible__interpreterhostvarsN)listkeysr   endswithr8   r9   )r    	task_varskeyr)   	localhosts        r#   _override_module_replaced_varsz+ActionModule._override_module_replaced_vars~   s     %	134	() 	#C~~j)cll>.JcN	#
 KK 	Dy,,%j1$7		 %	13<=V3WI/0 	0C~~j)cll>.J!*3	#	0r%   c           	      z   |
t               }| j                  j                  j                         }t        t
        |   ||      }~| j                  j                  | _	        |j                  dd      }|r| j                  j                  dk(  ru| j                  j                  d      | j                  j                  d      | j                  j                  d      g}dj                  |D cg c]  }|s|	 c}      |d	<   | j                  t        v r\| j                  j                  | _        | j                   j"                  r| j                  d| j                   j"                  | _        n| j                  t$        v rp| j                  j&                  d
   | _        | j                  j&                  j)                  d      r-| j                  d| j                  j&                  d   | _        d}| j                  j                  dk7  rd}	 | j                  j*                  }	|	R| j                  j                  g dt        z   t$        z   t0        z   vr#d|d<   d| j                  j                  z  |d<   |S |j)                  d      xs d|d<   d}
|j)                  d      }|d   j)                  |      }|j)                  d|      }|j)                  d      |j)                  d      fD cg c]  }|| }}t3               }t4        j6                  D ]f  }|d   j)                  |i       }t4        j8                  d   D ]  }|j)                  |d      }|s n t4        j:                  }|j=                  |       h d}|	|du rd}n|	|	|v rd}|j)                  dd      xs t4        j:                  }|j)                  dd      |||d<   d}|		|	|v rd}d}n|	|rd}|sh|red}t4        j6                  D ]I  }|d   j)                  |i       }t4        j8                  d   D ]  }|j)                  |d      }|s n |sI n. t>        j@                  jC                  t4        jD                        }|| j                   _#        d}t4        j6                  D ]I  }|d   j)                  |i       }t4        j8                  d   D ]  }|j)                  |d      }|s n |sI n t4        jD                  }|| j                   _$        	 tK        j(                  d| j                         }|| _        d| j                  _(        | jS                  |       |j)                  dd      d k(  r|
|}
}|j)                  d!d      }|j)                  d"d      }||t        dd#$      S d}|j)                  d%d      xs |j)                  d&d      } |stU        |j)                  d'd(      d)      r|rh|j)                  d*t                     j)                  d+d      }|s)|j)                  d+      xs | j                   jV                  }|s:t4        jX                  }n)|j)                  d+      xs | j                   jV                  }| jZ                  | jZ                  j]                  |      }|j)                  d,| j                   j^                        |d,<   |j)                  dd      d k(  r+| ja                  ||
||||v       }| jc                  |||      }n*| jc                  |
||      }| ja                  ||||||v       }|j)                  d%d      xs |j)                  d&d      } | jZ                  @| jZ                  j]                  |       } n$| je                  |-      }| je                  |-      }| |d.<   ||d!<   ||d"<   |j)                  d/d      }!| j                   jf                  }"|s| j                   jf                  rf|!sd| j                  t        t$        z   vrK| j                   jh                  d0k(  r2| j                   jj                  rd1| j                   jj                  z  }!nd2}!d| j                   _3        |!|d/<   | j                  t        t0        z   t$        z   v r|stm        |j)                  d3      tn              s[|j)                  d3g       }#tm        |#tp              r|#js                  d4      }#n"tm        |#tt        tv        f      rty        |#      g}#|#|d3<   d5|d3   vr|d3   j{                  d5       | j                  t        t$        z   v r|"r[| j                   jj                  rE|d3   j{                  d6t}        | j                  d7| j                   jj                  d8      z          n|1|d3   j{                  d6t}        | j                  d7|d8      z          n`|d3   j{                  d6t}        d9| j                  z        z          n2| j                  t0        v r |d3   j{                  d6t}        d:      z          |j                  | j                  d;||<             |S c c}w # t,        t.        f$ r d}	Y Gw xY wc c}w # tL        $ r9 tK        j(                  d| j                   | j                  jN                        }Y w xY w)=z9 generates params and passes them on to the rsync module Nuse_ssh_argsFsshssh_argsssh_common_argsssh_extra_args 	_ssh_argspodman_executablepodman_extra_argsr<   T)rQ   paramikor<   failedzsynchronize uses rsync to function. rsync needs to connect to the remote host via ssh, docker client or a direct filesystem copy. This remote host is being accessed via %s instead so it cannot work.msgansible_rsync_pathrsync_local_rsync_pathz	127.0.0.1inventory_hostnamerG   ansible_hostportansible_port	dest_portshell
executablemodepushpullsrcdestz9synchronize requires both src and dest parameters are set)rZ   r[   ansible_ssh_passansible_passwordset_remote_useryes)strictansible_delegated_varsansible_userprivate_keyr7   _local_rsync_password
rsync_pathsudozsudo -u %s rsyncz
sudo rsync
rsync_opts,z--blocking-ioz--rsh=z	 exec -u z -iz
%s exec -izbuildah run --zansible.posix.synchronize)module_argsrK   )Adictr   argscopysuperr   runr>   r?   r/   pop
get_optionjoinr0   
docker_cmd_docker_cmd_play_contextdocker_extra_argsr1   _optionsgetdelegate_toAttributeErrorKeyErrorr2   setr8   r9   MAGIC_VARIABLE_MAPPINGDEFAULT_REMOTE_PORTaddosr!   basenameDEFAULT_EXECUTABLErd   re   r   	TypeError
_new_stdin_remote_is_localrN   r   remote_userDEFAULT_REMOTE_USER_templartemplateprivate_key_filerB   r:   r$   becomebecome_methodbecome_user
isinstancer   r   splitintfloatr
   appendr   update_execute_module)%r    tmprK   	_tmp_argsresultrP   rR   aremote_transportr   src_hostr_   dest_host_inventory_vars	dest_hosthostiddest_host_idslocalhost_portsr)   localhost_varsport_varra   dest_is_localinv_portuse_delegatelocalhost_shell	shell_varlocalhost_executableexecutable_varnew_connectionri   rj   r3   passwordrt   r   tmp_rsync_opts	__class__s%                                       r#   r}   zActionModule.run   s
   0 I
 JJOO((*	|T.sI> "&!1!1!;!; }}^U;D,,66%?  ++J7  ++,=>  ++,<=H
 &)XX(.HQaq.H%IIk" !!V+#//::D!!33.2.>.>@R@R@d@d#e ##v-#//889LMD((,,-@A.2.>.>@P@P@Y@YZm@n#o  !%%0#	**00K 4#3#3#=#= F,.4F57=F>@GFH $H#F8% (,'7'7'A'AB 5M
 M *37K)L)WPW	%& &]]+?@#,Z#8#<#<=O#P ,00AST	/G/K/KL`/a/G/K/KN/[/] 0F".   0 0 %KK 	&D&z266tR@N44V< -%))(D9-
 ,,%	& #3u#< M$)E M ==6O!:O:O==d+3#)1	+& "{m'C $IL$)9  L
  0"O 	I!*:!6!:!:4!D!"!9!9'!B I&4&8&8D&IO& #	I #%''"2"213G3G"H'6D$ $(  	<!*:!6!:!:4!D&'&>&>|&L N+9+=+=nd+S(+ (	< ()';';$,@D)q!2!6!6w@R@R!S  .D 15D-//	: ==(F2%-yY mmE4(}}VT*;$,t)dee ==!3T:eimmL^`d>ey}}%6>uM$==)A46JNN~_cdD(}}^<^@R@R@^@^ 44$==8ZD<N<N<Z<ZD}}(}}--d3 (1}}]DDVDVDgDg'hIm$ }}VV,6**9hT8WfKfg++ItTB **8S$?++Iy$hZiNij/334FM  HQiQmQm  oA  CG  RHH}}(==11(; ))s)3C***5D-5	)*	% 	& ]]<6
 ##** !!((@V@V^dgm^m@m %%33v=))55%7$:L:L:X:X%X
%1
 ).D%",	, !!Vg%5%>>|immL9?K!*|R!@nl;%3%9%9#%>Ne=&-n&=%>N*8	,'i&==,'..?%%&8d00<<l+228k`d`p`prv  sE  sE  sQ  sQ  KR  ?S  4S  T%l+228k`d`p`prvJw>x3xyl+228k,Y]YiYiJi>j3jk''72,'..x+FV:W/WX 	d**+FT]ir*sto /I. ) 	K	80\  q!2!6!6w@R@RTXTdTdToTo!pqs6   .i6ii 1i3 i8 i0/i08>j:9j:)NN)__name__
__module____qualname__r$   r*   r5   r:   rB   rN   r}   __classcell__)r   s   @r#   r   r   %   s.    0B.:00d dr%   r   )
__future__r   r   r   type__metaclass__os.pathr   ansibler   r8   ansible.module_utils.sixr   ansible.module_utils.six.movesr   ansible.module_utils._textr
   /ansible.module_utils.common._collections_compatr   )ansible.module_utils.parsing.convert_boolr   ansible.plugins.actionr   ansible.plugins.loaderr   r0   r1   r2   r    r%   r#   <module>r      sT   " C B  " 1 6 . K = - 4 
K	I1
2U: Ur%   