Ansible - dotnet nuget add source delegation error

22 views Asked by At

I get the following error when trying to run dotnet nuget add source of my ADO private repository to a windows target machine:

"stdout": "error: The requested operation cannot be completed. The computer must be trusted for delegation and the current user account must be configured to allow delegation.

The Ansible task is:

    - name: Add private NuGut source
      win_shell: "dotnet nuget add source https://pkgs.dev.azure.com/XXXX/_packaging/GlobalPackageRegistry/nuget/v3/index.json -n GlobalPackageRegistry -u [email protected] -p {{ token }} --valid-authentication-types basic"
      when: ansible_facts['os_family'] == "Windows"

Ansible playbook command:

ansible-playbook -i agents.yml set_nuget.yml --extra-vars "token=ZZZZZZZZZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

If I run the command with the same user it is logging into in Ansible on the windows target machine, the command runs fine and it is able to create a NuGet.Config file just fine.

1

There are 1 answers

0
PanzerRage On

used this and it worked: https://jarrodstech.net/fix-the-computer-must-be-trusted-for-delegation-and-the-current-user-account-must-be-configured-to-allow-delegation/

$registryPath = "HKLM:\Software\Microsoft\Cryptography\Protect\Providers\df9d8cd0-1501-11d1-8c7a-00c04fc297eb"

$valueName = "ProtectionPolicy"
$hexValue = "1"

if (-not (Test-Path $registryPath)) {
    New-Item -Path $registryPath -Force | Out-Null
}

# Set the DWORD value
Set-ItemProperty -Path $registryPath -Name $valueName -Value $hexValue -Type DWORD