
    Vh2                     @    d dl Z d dlZd dlmZ d dlmZ ddZd Zd Z	y)    N)	to_native)parsec                     d}| | j                  dd      } d}nd}t        j                  t        j                  |            }|j                  | |      S )Nzhhttps://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'z''z        <powershell>
        $admin = [adsi]('WinNT://./administrator, user')
        $admin.PSBase.Invoke('SetPassword', '${PASS}')
        Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('${SCRIPT}'))
        </powershell>
        z        <powershell>
        $admin = [adsi]('WinNT://./administrator, user')
        Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('${SCRIPT}'))
        </powershell>
        )PASSSCRIPT)replacestringTemplatetextwrapdedentsafe_substitute)passwd
script_url
script_tpltpls       i/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/amazon/aws/plugins/module_utils/tower.py_windows_callback_scriptr      s_    r  T*

 //(//*5
6CF:>>    c                     t        j                  |      }t        j                  |       } |j                  dd      }d}t        j                  t        j                  |            }|j                  | ||      S )Nr   z'"'"'a      #!/bin/bash
    set -x

    retry_attempts=10
    attempt=0
    while [[ $attempt -lt $retry_attempts ]]
    do
      status_code=$(curl --max-time 10 -v -k -s -i         --data 'host_config_key=${host_config_key}'         'https://${tower_address}/api/v2/job_templates/${template_id}/callback/'         | head -n 1         | awk '{print $2}')
      if [[ $status_code == 404 ]]
        then
        status_code=$(curl --max-time 10 -v -k -s -i           --data 'host_config_key=${host_config_key}'           'https://${tower_address}/api/v1/job_templates/${template_id}/callback/'           | head -n 1           | awk '{print $2}')
        # fall back to using V1 API for Tower 3.1 and below, since v2 API will always 404
      fi
      if [[ $status_code == 201 ]]
        then
        exit 0
      fi
      attempt=$(( attempt + 1 ))
      echo "$${status_code} received... retrying in 1 minute. (Attempt $${attempt})"
      sleep 60
    done
    exit 1
    )tower_addresstemplate_idhost_config_key)urlparsequoter	   r
   r   r   r   r   )r   r   r   r   r   s        r   _linux_callback_scriptr   &   sj    ..-KNN=1M%--c9=OJ@ //(//*5
6C]etuur   c                 J    |rt        t        |            S t        | ||      S )N)r   )r   r   r   )r   job_template_idr   windowsr   s        r   tower_callback_scriptr    O   s%    1@AA!-/RRr   )N)
r
   r   ansible.module_utils._textr   %ansible.module_utils.six.moves.urllibr   r   r   r   r     r   r   <module>r$      s%      0 C?2&vRSr   