CredSSP isn't really the best way to go about this. And I think this post should go on Git as Ansible needs a better way to cover double-hops.
CredSSP in the WWW-Authenticate headerIf you cannot use Kerberos (for whatever reason) then CredSSP can also be done to achieve the same result but it does have some security implications you should be aware off beforehand. When people say CredSSP is insecure, that is definitely not right, you just need to be aware of the risks involved and mitigate them if necessary.
ansible_winrm_kerberos_delegation: True<hasgappqba2303> WINRM CLOSE SHELL: 22A19915-A7B0-4AFB-B840-263A9980023A<hasgappqba2302> WINRM RESULT u'<Response code 1, out "", err "Exception calling "R">'<hasgappqba2302> WINRM STDOUT <hasgappqba2302> WINRM STDERR Exception calling "Run" with "1" argument(s): "Exception calling "Invoke" with "0" argument(s): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Access is denied"" At line:47 char:5 + $output = $entrypoint.Run($payload) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : ScriptMethodRuntimeException # cat group_vars/windows.yml# it is suggested that these be encrypted with ansible-vault:# ansible-vault edit group_vars/windows.yml
ansible_user: ansible#password goes here when you don't want to use -k option.ansible_password: "PASSWORD_HERE"ansible_port: 5986ansible_connection: winrmansible_winrm_transport: kerberosansible_winrm_scheme: httpsansible_winrm_server_cert_validation: ignoreansible_winrm_kerberos_delegation: true
# cat vscode.yaml---- hosts: windows tasks: - name: Install Visual studio Code win_package: path: \\some\dfs\path\VSCodeSetup-1.8.1.exe creates_path: "C:\\Program Files\\Microsoft VS Code\\Code.exe" arguments: /verysilent state: present
TASK [Check Visual studio Code file] ***************************************************************************************************************************************************************************************************************************************************************************************task path: /ansible/scripts/win_stat.yaml:4Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_stat.ps1Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_stat.ps1<hasgappqba2302.domain> ESTABLISH WINRM CONNECTION FOR USER: ansible@domain on PORT 5986 TO hasgappqba2302.domain<hasgappqba2303.domain> ESTABLISH WINRM CONNECTION FOR USER: ansible@domain on PORT 5986 TO hasgappqba2303.domaincreating Kerberos CC at /tmp/tmpMi3utNcreating Kerberos CC at /tmp/tmpUIFzBScalling kinit for principal ansible@domaincalling kinit for principal ansible@domainkinit succeeded for principal ansible@domain<hasgappqba2302.domain> WINRM CONNECT: transport=kerberos endpoint=https://hasgappqba2302.domain:5986/wsmankinit succeeded for principal ansible@domain<hasgappqba2303.domain> WINRM CONNECT: transport=kerberos endpoint=https://hasgappqba2303.domain:5986/wsman<hasgappqba2302.domain> WINRM OPEN SHELL: FA267E6D-94C1-4BF1-AD41-75900BCC25DC<hasgappqba2303.domain> WINRM OPEN SHELL: 47C7EA5A-202C-4560-B54B-B614A3C8B9C7EXEC (via pipeline wrapper)EXEC (via pipeline wrapper)<hasgappqba2302.domain> WINRM EXEC 'PowerShell' ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted', '-']<hasgappqba2303.domain> WINRM EXEC 'PowerShell' ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted', '-']<hasgappqba2303.domain> WINRM RESULT u'<Response code 1, out "{"changed":false,"st", err "Test-Path : Access i">'<hasgappqba2303.domain> WINRM STDOUT {"changed":false,"stat":{"exists":false}}
<hasgappqba2303.domain> WINRM STDERR Test-Path : Access is deniedAt line:91 char:5+ If (Test-Path -Path $path)+ ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (\\some\dfs\path\j...Setup-1.8.1.exe:String) [Test-Path], UnauthorizedAc cessException + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.TestPathCommand
<hasgappqba2303.domain> WINRM CLOSE SHELL: 47C7EA5A-202C-4560-B54B-B614A3C8B9C7ok: [hasgappqba2303.domain] => { "changed": false, "stat": { "exists": false }}<hasgappqba2302.domain> WINRM RESULT u'<Response code 1, out "{"changed":false,"st", err "Test-Path : Access i">'<hasgappqba2302.domain> WINRM STDOUT {"changed":false,"stat":{"exists":false}}
<hasgappqba2302.domain> WINRM STDERR Test-Path : Access is deniedAt line:91 char:5+ If (Test-Path -Path $path)+ ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (\\some\dfs\path\j...Setup-1.8.1.exe:String) [Test-Path], UnauthorizedAc cessException + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.TestPathCommand
<hasgappqba2302.domain> WINRM CLOSE SHELL: FA267E6D-94C1-4BF1-AD41-75900BCC25DCok: [hasgappqba2302.domain] => { "changed": false, "stat": { "exists": false }}META: ran handlersMETA: ran handlers
PLAY RECAP *****************************************************************************************************************************************************************************************************************************************************************************************************************hasgappqba2302.domain : ok=2 changed=0 unreachable=0 failed=0hasgappqba2303.domain : ok=2 changed=0 unreachable=0 failed=0
ansible-playbook 2.5.0 (devel 575e9e9294) last updated 2018/02/06 08:39:18 (GMT +300) config file = /ansible/scripts/ansible.cfg configured module search path = [u'/home/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /ansible/scripts/ansible/lib/ansible executable location = /ansible/scripts/ansible/bin/ansible-playbook python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] Using /ansible/scripts/ansible.cfg as config file setting up inventory plugins Parsed /scripts/windows-inventory.yml inventory source with yaml plugin Loading callback plugin default of type stdout, v2.0 from /ansible/scripts/ansible/lib/ansible/plugins/callback/default.pyc
<hasgappqba2303.domain> WINRM STDERR<hasgappqba2303.domain> WINRM CLOSE SHELL: AC3CF2B5-A044-43DF-A24B-53DB23624226The full traceback is:Exception calling "RunAsUser" with "7" argument(s): "LogonUser failed (The user name or password is incorrect,Win32ErrorCode 1326)"At line:1062 char:9+ $result = [Ansible.BecomeUtil]::RunAsUser($username, $passwor ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : Win32Exception
fatal: [hasgappqba2303.domain]: FAILED! => { "changed": false, "failed": true, "msg": "Exception calling \"RunAsUser\" with \"7\" argument(s): \"LogonUser failed (The user name or password is incorrect, Win32ErrorCode 1326)\""}