运行win_command任务时引用转义的问题

时间:2019-09-07 17:14:21

标签: ansible

我对Win 16服务器执行了简单的win_command任务

- name: Create or update attunity service
  win_command: |
    xdbcdcsvc.exe config {{role_vars.cdc_svc_name}}
      connect= "server={{inventory_hostname}};trusted_connection=yes;" 
      key={{role_vars.cdc_master_pwd}} 
      svcacct= {{role_vars.svc_account.name}}@{{win_domain_name}} {{role_vars.svc_account.pwd}}

它呈现为

fatal: [cdpdtsrv.tsu-int.tsu]: FAILED! => {
    "changed": true,
    "cmd": "xdbcdcsvc.exe create SvcTest connect= \"server=cdpdtsrv.tsu-int.tsu;trusted_connection=yes;\" key=XXX svcacct= control\\svc_cdcowner_1_1 XXX",
    "delta": "0:00:00.330054",
    "end": "2019-09-09 06:08:35.712763",
    "msg": "non-zero return code",
    "rc": 2,
    "start": "2019-09-09 06:08:35.382709",
    "stderr": "",
    "stderr_lines": [],
    "stdout": "ADMIN: 2019-09-09 06:08:35.686000000\tERROR\tODBC error: RetCode: SQL_ERROR  SqlStat: 28000 NativeError: 18456 Message: [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'CDPDTSRV-30-3\\Administrator'.\r\n",
    "stdout_lines": [
        "ADMIN: 2019-09-09 06:08:35.686000000\tERROR\tODBC error: RetCode: SQL_ERROR  SqlStat: 28000 NativeError: 18456 Message: [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'CDPDTSRV-30-3\\Administrator'."
    ]
}

这失败。但是,当我直接在目标计算机上的cmd提示符下运行此命令时

xdbcdcsvc.exe create CAB_CDPStagingCDC connect= "server=cdpvault.tsu-int.tsu;trusted_connection=yes;" key=XXX svcacct= control\svc_cdcowner_1_1 XXX 

成功...

更新: 我不太确定,但是我觉得可能是xdbcdcsvc问题...当我在cmd提示符下插入以下行时,它会起作用...

xdbcdcsvc.exe create SvcTest connect= "server=cdpvault.tsu-int.tsu;trusted_connection=yes;" key=6DnEzZt2tuy5X5aQuh8y svcacct= control\svc_cdcowner_1_1 6DnEzZt2tuy5X5aQuh8y

当我尝试运行以下任务时,它会失败

- name: Create or update attunity service
  win_command: xdbcdcsvc.exe create SvcTest connect= "server=cdpvault.tsu-int.tsu;trusted_connection=yes;" key=6DnEzZt2tuy5X5aQuh8y svcacct= control\svc_cdcowner_1_1 6DnEzZt2tuy5X5aQuh8y
  args:
    chdir: C:\Program Files\Change Data Capture for Oracle by Attunity

使用

fatal: [cdpdtsrv.tsu-int.tsu]: FAILED! => {
    "changed": true,
    "cmd": "xdbcdcsvc.exe create SvcTest connect= \"server=cdpdtsrv.tsu-int.tsu;trusted_connection=yes;\" key=6DnEzZt2tuy5X5aQuh8y svcacct= control\\svc_cdcowner_1_1 6DnEzZt2tuy5X5aQuh8y",
    "delta": "0:00:00.330054",
    "end": "2019-09-09 06:08:35.712763",
    "msg": "non-zero return code",
    "rc": 2,
    "start": "2019-09-09 06:08:35.382709",
    "stderr": "",
    "stderr_lines": [],
    "stdout": "ADMIN: 2019-09-09 06:08:35.686000000\tERROR\tODBC error: RetCode: SQL_ERROR  SqlStat: 28000 NativeError: 18456 Message: [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'CDPDTSRV-30-3\\Administrator'.\r\n",
    "stdout_lines": [
        "ADMIN: 2019-09-09 06:08:35.686000000\tERROR\tODBC error: RetCode: SQL_ERROR  SqlStat: 28000 NativeError: 18456 Message: [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'CDPDTSRV-30-3\\Administrator'."
    ]
}

0 个答案:

没有答案