Ansible - dotnet nuget 添加源委托错误

问题描述 投票:0回答:1

尝试将我的 ADO 私有存储库的 dotnet nuget add 源运行到 Windows 目标计算机时,出现以下错误:

“stdout”:“错误:无法完成请求的操作。必须信任计算机才能进行委派,并且当前用户帐户必须配置为允许委派。

Ansible 的任务是:

    - 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 剧本命令:

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

如果我使用登录到 Windows 目标计算机上的 Ansible 的同一用户运行该命令,则该命令运行良好,并且能够很好地创建 NuGet.Config 文件。

.net-core ansible nuget ansible-2.x windows-server
1个回答
0
投票

使用了这个并且它起作用了:https://jarrodstech.net/fix-the-computer-must-be-trusted-for-delegation-and-the-current-user-account-must-be-configured-to-允许委托/

$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
© www.soinside.com 2019 - 2024. All rights reserved.