AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1012719
Accepted
user1174838
user1174838
Asked: 2020-04-18 00:20:24 +0800 CST2020-04-18 00:20:24 +0800 CST 2020-04-18 00:20:24 +0800 CST

ansible win_command 失败但在手动运行命令时有效

  • 772

我正在尝试运行 New-WdsClient PowerShell cmdlet 或 wdsutil /add-device,我真的不在乎最终使用哪个,只要它有效。

当我运行 'wdsutil.exe /add-device /device:new_client /id:aabbccddeeff /BootImagePath:"Boot\x64\Images\boot-(6).wim" ' 它工作,当我从 Ansible 运行相同的我得到 "stdout_lines": [ "", "Windows Deployment Services Management Utility [Version 10.0.14393.0]", "© 2016 Microsoft Corporation. All rights reserved.", "", "", "An error occurred while trying to execute the command.", "Error Code: 0xC103013A", "Error Description: The specified server name is invalid or does not exist in the directory service.", ""

我完全被难住了。

Ansible 的作用只是: - name: Pre Stage WDS Client win_command: powershell.exe - args: stdin: 'wdsutil.exe /add-device /device:{{ var_wds_client_name }} /id:{{ var_wds_client_mac }} /BootImagePath:"Boot\x64\Images\boot-(6).wim"'

使用 New-WdsClient 我什至没有走到这一步......

有任何想法吗?

-- 编辑 1 --

当我将 win_whoami 作为临时运行时,它可以工作: ansible wds-server --become --become-method runas --become-user DOMAIN\Administrator --module-name win_whoami 2> /dev/null| egrep "SeDebug|High" "account_name": "High Mandatory Level", "account_name": "High Mandatory Level", "SeDebugPrivilege": "enabled"

当我以 adhoc 方式运行 wdsutil 时, ansible wds-server --become --become-method runas --become-user DOMAIN\Administrator --module-name win_command -a "wdsutil.exe /add-device /device:client /id:0001a5a0c267 /BootImagePath:Boot\x64\Images\boot-(6).wim"我得到:

Windows Deployment Services Management Utility [Version 10.0.14393.0] © 2016 Microsoft Corporation. All rights reserved.

An error occurred while trying to execute the command. Error Code: 0xC103013A Error Description: The specified server name is invalid or does not exist in the directory service.

non-zero return code

ansible windows-server-2016 wds
  • 2 2 个回答
  • 2691 Views

2 个回答

  • Voted
  1. Anderson Medeiros Gomes
    2020-04-18T01:14:35+08:002020-04-18T01:14:35+08:00

    这是一个猜测,因为我没有方便的 Windows WDS 部署来执行测试。

    wdsutil根据Microsoft Docs的说法,我认为由于缺乏所需的提升权限,该任务没有通过 Ansible 运行。您可能需要使用become关键字才能使任务起作用:

    - name: Pre Stage WDS Client
      win_command: powershell.exe -
      args:
        stdin: 'wdsutil.exe /add-device /device:{{ var_wds_client_name }} /id:{{ var_wds_client_mac }} /BootImagePath:"Boot\x64\Images\boot-(6).wim"'
      become: yes
      become_method: runas
    

    或者,或者,wdsutil直接调用:

    - name: Pre Stage WDS Client
      win_command: 'wdsutil.exe /add-device /device:{{ var_wds_client_name }} /id:{{ var_wds_client_mac }} /BootImagePath:"Boot\x64\Images\boot-(6).wim"'
      become: yes
      become_method: runas
    

    使用以下临时调用检查是否授予 Ansible 管理权限:

    $ ansible windows_wds_server --become --become-method runas --module-name win_whoami 
    

    返回的 JSON 对象应将privileges.SeDebugPrivilege属性设置为enabled.

    参考:https ://docs.ansible.com/ansible/latest/user_guide/become.html#administrative-rights

    • 0
  2. Best Answer
    user1174838
    2020-04-20T04:26:51+08:002020-04-20T04:26:51+08:00

    首先,向大家道歉。

    Ansible 服务是一个 RHEL 盒子,它实际上与一个中间 Windows 盒子对话,后者随后与 WDS 服务器对话。

    我的一位同事发现这个链接为我们解决了这个问题。

    谢谢大家的建议。

    • 0

相关问题

  • 重复的 Ansible 任务

  • 无法形成站点中的文件的链接,该链接可用于使用 ansible 在远程服务器中启用的目录站点?

  • 如何执行 ansible 的特定角色?

  • Ansible 和 rbash

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve