로컬 사용자를 사용하여 Windows 서버에 로그인 한 다음 Active Directory 사용자를 사용하여 네트워크 드라이브를 매핑하고 Ansible으로 자동화 된 설치 프로그램을 실행하고 싶습니다.Windows 공유에서 설치 관리자 실행
나는 this question의 제안에 따라 PowerShell 스크립트를 만들고 마운트 및 설치를 수행했습니다. 다음과 같이 그 스크립트를 사용 :
재고 :
[winserver]
windows
[winserver:vars]
ansible_user="local_user"
ansible_password="[email protected]"
ansible_connection="winrm"
ansible_winrm_cert_validation=ignore
win_user="domain\aduser"
win_pass="[email protected]"
작업 YAML :
---
- name: Mount and run a script
script: 'files/maprun.ps1 -map_user {{ win_user }} -map_password {{ win_pass }} -script z:\ascript.ps1'
그리고 maprun.ps1
스크립트는 다음이 포함
param(
$map_user,
$map_password,
$script
)
$PWord="$map_password"|ConvertTo-SecureString -AsPlainText -Force
$myCreds=New-Object System.Management.Automation.PsCredential($map_user,$PWord)
New-PSDrive -Name "Z" -PSProvider "FileSystem" -Root "\\domain\share" -Credential $myCreds
echo Invoke-Command -ScriptBlock $script
그리고 나는 오류 :
New-PSDrive: A specified logon session does not exist. It may already have
been terminated
대부분의 조회수는 이중 홉 문제에 대해 이야기하지만 원격 스크립트에 다른 자격 증명을 지정하려고 시도하므로 이중 홉 문제는 아닙니다. 다른 대답은 이것이 가능해야한다고 제안합니다. 이 스크립트는 대화식 모드에서 작동하므로 일괄 처리 모드와 관련이 있습니다. 이 아이디어를 얻으려면 어떻게해야할까요?
Red Hat Enterprise Linux에서 An 2.3.1.0을 사용하고 있습니다. Windows는 Windows Server 2012 R2입니다. 스크립트는 수동으로 입력되었으므로 오타를 유감스럽게 생각합니다.
가능성은 사용자 이름이나 암호를 시도 공백이나 다른 포함 특수 문자 및 어떻게 든 인용 부호가 필요합니까? 가능한 구문에 익숙하지 않지만, 예를 들어'-map_user "{{win_user}}"-map_password {{win_pass}} "' – TessellatingHeckler
실제로 나는 전체 라인을 인용했습니다. 패스워드는 틀린 패스워드로 바꾸면 다른 에러가 나옵니다 :'New-PSDrive : 지정한 네트워크 패스워드가 맞지 않습니다. ' –