驗證 WebSphere Automation 與 WebSphere Application Server 或 WebSphere Application Server Liberty 伺服器之間的遠端存取。
開始之前
這項作業需要 WebSphere Automation 叢集的管理存取權。
程序
- 執行
runcli testConnection 指令。 runcli
testConnection 指令可以從 runbook-manager Pod 的主控台執行。
MANAGER_POD=$(oc get pod -l app.kubernetes.io/component=runbook-manager -o name | head -n 1)
oc rsh $MANAGER_POD runcli testConnection <hostname> [operatingSystem]
請將受管理伺服器的主機名稱作為參數傳遞,或將作業系統名稱作為參數傳遞。 請參閱下列範例。
oc rsh $MANAGER_POD runcli testConnection myvm linux
工作啟動時會嘗試使用所配置的 SSH 或 WinRM 參數來連接至受管理伺服器。 請參閱下列範例輸出。
2021 6:47:23 PM com.ibm.ws.automation.core.runbook.manager.RunbookManagerCLI clientMode
參考資訊: 啟動中
已建立工作: test-connection-1634928445267
若要查看工作日誌,請執行 :oc logs --tail=100 -l job-name=test-connection-1634928445267
- 請檢查工作日誌中是否有任何連線問題。
成功連線的輸出:
[11/02/21 19:05:36:746 UTC] 1 com.ibm.ws.automation.core.runbook.runner.RunbookRunnerCLI INFO appMode Runbook Runner Starting
[11/02/21 19:05:38:952 UTC] 1 com.ibm.ws.automation.core.runbook.runner.RunbookRunnerCLI INFO start Request received to execute runbook: test-connection against server: test-server.example.com (correlationId: 1635879932990)
[11/02/21 19:05:39:033 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook Here is the standard output of the command:
[11/02/21 19:05:39:129 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook was:
[11/02/21 19:05:39:129 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook hosts:
[11/02/21 19:05:39:129 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook test-server.example.com:
[11/02/21 19:05:39:130 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook ansible_connection: ssh
[11/02/21 19:05:39:130 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook ansible_shell_type: powershell
[11/02/21 19:05:39:130 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook ansible_user: Administrator
[11/02/21 19:05:39:133 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook Agent pid 48
[11/02/21 19:05:39:138 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook The known_hosts file is not present
[11/02/21 19:05:39:138 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook ANSIBLE_HOST_KEY_CHECKING=<notset>
[11/02/21 19:05:40:049 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook No config file found; using defaults
[11/02/21 19:05:40:438 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook
[11/02/21 19:05:40:438 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook PLAY [Test Connection] *********************************************************
[11/02/21 19:05:40:447 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook
[11/02/21 19:05:40:447 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook TASK [test : Check PowerShell Version] *****************************************
[11/02/21 19:05:46:192 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook changed: [test-server.example.com] => {"changed": true, "cmd": "Write-Output (\"PowerShell version: \" + $PSVersionTable.PSVersion.Major + \".\" + $PSVersionTable.PSVersion.Minor)\nif ($PSVersionTable.PSVersion.Major -lt 5) {\n Write-Output \"ERROR: PowerShell version 5 or later is required.\"\n Exit 25\n}", "delta": "0:00:00.921839", "end": "2021-11-02 07:05:45.760941", "rc": 0, "start": "2021-11-02 07:05:44.839102", "stderr": "", "stderr_lines": [], "stdout": "PowerShell version: 5.1\r\n", "stdout_lines": ["PowerShell version: 5.1"]}
[11/02/21 19:05:46:196 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook
[11/02/21 19:05:46:196 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook PLAY RECAP *********************************************************************
[11/02/21 19:05:46:196 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook test-server.example.com : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[11/02/21 19:05:46:197 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook
[11/02/21 19:05:46:264 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook Here is the standard error of the command (if any):
[11/02/21 19:05:46:265 UTC] 1 com.ibm.ws.automation.core.runbook.runner.AnsibleRunner INFO runRunbook Identity added: /was/win/ssh_private_key_file (example.user@example.com)
[11/02/21 19:05:46:265 UTC] 1 com.ibm.ws.automation.core.runbook.runner.RunbookRunnerCLI INFO start Ansible return code=0
[11/02/21 19:05:46:265 UTC] 1 com.ibm.ws.automation.core.runbook.runner.RunbookRunnerCLI INFO stop Runbook Runner Stopping
如果沒有明顯的錯誤或完成訊息,請搜尋關鍵字 stdout、 stdout_lines、 stderr 和 stderr_lines。
附註: 即使伺服器符合 PowerShell 版本需求,也可能會出現 PowerShell 需求行。 您可以忽略此陳述。
如果您在測試連線時遇到問題,請參閱下列疑難排解提示。
- 遺漏 wsa-ansible 或 wsa-ansible-win 密鑰
ERROR: The /was/ssh directory with the Ansible connection
parameters is empty. Make sure the wsa-ansible secret exists.
SSH 或 WinRM 連線參數遺漏 wsa-ansible 或 wsa-ansible-win 密鑰。 請參閱 設定安全遠端存取。
- 無法解析主機名稱
Failed to connect to the host via ssh: ssh: Could not
resolve hostname <hostname>
部分伺服器可能配置了無法由 DNS 解析的主機名稱。 在這類情況下,您可能需要使用自訂主機對映來配置 WebSphere Automation。 使用 WebSphereAutomation 自訂資源 中的 .runbookManager.runbookRunner.hostAliases 參數,以提供更多主機或 IP 對映。 例如,
apiVersion: automation.websphere.ibm.com/v1
kind: WebSphereAutomation
metadata:
name: wsa
spec:
runbookManager:
runbookRunner:
hostAliases:
- hostnames:
- myvm
ip: 9.46.84.208
- 主機金鑰驗證失敗
Failed to connect to the host via ssh: Host key verification
failed.
WebSphere Automation 會驗證主機金鑰,但其中一部伺服器的主機金鑰已變更。 如果是有意地變更主機金鑰,請使用更新的金鑰更新 wsa-ansible-known-hosts 配置。 如需詳細資料,請參閱 設定 WebSphere Automation for SSH 至 Linux 或 UNIX 伺服器 。