実現したいこと
Windows Serverに対してAnsibleにて環境構築を行いたいと考えております。
win_pingコマンドを実行した際に以下のエラーが表示されている状況です。
※双方向にpingは届いております。
設定値について足りない部分またトラブルシューティングする方法等ございましたらご教示頂けますと幸いです。
検証環境
- Ansible実行対象ホスト
Windows Server 2016 Dataceter
PowerShell 5.1
.NET Framework 4.6
WindowsFirewall 無効化
- Ansibleサーバ
CentOS7.6
pywinrm 0.3.0
ansible 2.8.1
発生している問題・エラーメッセージ1
bash
1${IP_ADDRESS} | UNREACHABLE! => { 2 "changed": false, 3 "msg": "ssl: the specified credentials were rejected by the server", 4 "unreachable": true 5}
インベントリファイル1
YAML
1[windows] 2${IP_ADDRESS} 3 4[windows:vars] 5ansible_user=Administrator 6ansible_password=xxxxxxxx 7ansible_port=5986 8ansible_connection=winrm 9ansible_winrm_server_cert_validation=ignore
発生している問題・エラーメッセージ2
bash
1${IP_ADDRESS} | UNREACHABLE! => { 2 "changed": false, 3 "msg": "plaintext: the specified credentials were rejected by the server", 4 "unreachable": true 5}
インベントリファイル2
YAML
1[windows] 2${IP_ADDRESS} 3 4[windows:vars] 5ansible_user=Administrator 6ansible_password=xxxxxxxx 7ansible_port=5985 8ansible_connection=winrm
実施したコマンド
ansible
1ansible windows -i hosts -m win_ping
試したこと
以下の手順でWindows ServerのWinRM設定を行いました。
Ansibleサーバについては上記のモジュールをインストールして使用しております。
- 公式のスクリプトをダウンロード
PowerShell
1Invoke-WebRequest -Uri https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile ConfigureRemotingForAnsible.ps1
- winrmを有効化
PowerShell
1powershell -ExecutionPolicy RemoteSigned .\ConfigureRemotingForAnsible.ps1
- ネットワークをプライベートに変更
PowerShell
1Set-NetConnectionProfile -InterfaceAlias (Get-NetConnectionProfile -IPv4Connectivity Internet).InterfaceAlias -NetworkCategory Private
- Basic認証許可
PowerShell
1winrm set winrm/config/service/auth '@{Basic="true"}'
- 平文許可
PowerShell
1winrm set winrm/config/service '@{AllowUnencrypted="true"}'
補足情報
- 上記に「ansible_port=5986」と「ansible_port=5985」の両方を記載した理由については、
できれば暗号通信したいと思いますが、できないようなら平文でも良いという考えのもとです。
- ちなみにですが、Windows10の環境(本件のために作成した環境ではありません)で
同様の設定を行うと、win_pingの実行に成功しました。
設定の差分などがあえるとは思えませんが、確認したほうが良い設定値などございますでしょうか。
windows10の環境で成功したことから、インベントリファイルについては問題ないと思っております。
- winrmの設定値については以下のようになっております。
PowerShell
1PS C:\Users\Administrator> winrm get winrm/config 2Config 3 MaxEnvelopeSizekb = 500 4 MaxTimeoutms = 60000 5 MaxBatchItems = 32000 6 MaxProviderRequests = 4294967295 7 Client 8 NetworkDelayms = 5000 9 URLPrefix = wsman 10 AllowUnencrypted = true 11 Auth 12 Basic = true 13 Digest = true 14 Kerberos = true 15 Negotiate = true 16 Certificate = true 17 CredSSP = false 18 DefaultPorts 19 HTTP = 5985 20 HTTPS = 5986 21 TrustedHosts 22 Service 23 MaxConcurrentOperations = 4294967295 24 MaxConcurrentOperationsPerUser = 1500 25 EnumerationTimeoutms = 240000 26 MaxConnections = 300 27 MaxPacketRetrievalTimeSeconds = 120 28 AllowUnencrypted = true 29 Auth 30 Basic = true 31 Kerberos = true 32 Negotiate = true 33 Certificate = false 34 CredSSP = false 35 CbtHardeningLevel = Relaxed 36 DefaultPorts 37 HTTP = 5985 38 HTTPS = 5986 39 IPv4Filter = * 40 IPv6Filter = * 41 EnableCompatibilityHttpListener = false 42 EnableCompatibilityHttpsListener = false 43 CertificateThumbprint 44 AllowRemoteAccess = true 45 Winrs 46 AllowRemoteShellAccess = true 47 IdleTimeout = 7200000 48 MaxConcurrentUsers = 2147483647 49 MaxShellRunTime = 2147483647 50 MaxProcessesPerShell = 2147483647 51 MaxMemoryPerShellMB = 2147483647 52 MaxShellsPerUser = 2147483647

あなたの回答
tips
プレビュー