ansibleでwinrmに接続を確認しました。
WIndows 2012R2側の準備
提供されているスクリプトでwinrmの設定をします。
PS C:\> mkdir work Directory: C:\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 5/25/2016 1:01 PM work PS C:\> cd work PS C:\work> PS C:\work> Invoke-WebRequest -Uri https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile ConfigureRemotingForAnsible.ps1 PS C:\work> dir Directory: C:\work Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 5/25/2016 1:01 PM 8582 ConfigureRemotingForAnsible.ps1 PS C:\work> powershell -ExecutionPolicy RemoteSigned .\ConfigureRemotingForAnsible.ps1 Self-signed SSL certificate generated; thumbprint: CD15EA653B190875E4431C6C897019F77427F121 wxf : http://schemas.xmlsoap.org/ws/2004/09/transfer a : http://schemas.xmlsoap.org/ws/2004/08/addressing w : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd lang : en-US Address : http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ReferenceParameters : ReferenceParameters Ok. PS C:\work> Get-NetConnectionProfile -IPv4Connectivity Internet Name : Network 2 InterfaceAlias : Ethernet InterfaceIndex : 12 NetworkCategory : Public IPv4Connectivity : Internet IPv6Connectivity : NoTraffic PS C:\work>
ansible側の準備
pywinrmをインストールする。
$ sudo pip install pywinrm
インベントリを準備して普通に繋がりました。
$ cat ec2-hosts [windows] ec2-54-19-62-137.ap-northeast-1.compute.amazonaws.com [windows:vars] ansible_ssh_user=Administrator ansible_ssh_pass=パスワード ansible_ssh_port=5986 ansible_connection=winrm ansible_winrm_server_cert_validation=ignore $ make win-test ansible -i ec2-hosts windows -m setup ec2-54-19-62-137.ap-northeast-1.compute.amazonaws.com | SUCCESS => { "ansible_facts": { "ansible_architecture": "64-bit", "ansible_date_time": { "date": "5/25/2016", "day": "25", "hour": "13", "iso8601": "2016-05-25T13:19:13", "minute": "19", "month": "05", "year": "2016" }, "ansible_distribution": "Microsoft Windows NT 6.3.9600.0", "ansible_distribution_version": "6.3.9600.0", "ansible_fqdn": "WIN-RITVMDQU2RI", "ansible_hostname": "WIN-RITVMDQU2RI", "ansible_interfaces": [ { "default_gateway": "72.131.216.1", "dns_domain": "ap-northeast-1.compute.internal", "interface_index": 12, "interface_name": "AWS PV Network Device #0" } ], "ansible_ip_addresses": [ "72.131.216.28", ], "ansible_lastboot": "2016-05-25 12:32:33Z", "ansible_os_family": "Windows", "ansible_os_name": "Microsoft Windows Server 2012 R2 Standard", "ansible_powershell_version": 4, "ansible_system": "Win32NT", "ansible_totalmem": 1073332224, "ansible_uptime_seconds": 2800, "ansible_winrm_certificate_expires": "2017-05-25 13:13:12" }, "changed": false } $
ネットワークをprivateにして検証
NetworkCategoryをPrivateに設定しても問題なく動く。(結果省略)
PS C:\work> Set-NetConnectionProfile -InterfaceAlias (Get-NetConnectionProfile -IPv4Connectivity Internet).InterfaceAlias -NetworkCategory Private PS C:\work> Get-NetConnectionProfile -IPv4Connectivity Internet Name : Network 2 InterfaceAlias : Ethernet InterfaceIndex : 12 NetworkCategory : Private IPv4Connectivity : Internet IPv6Connectivity : NoTraffic PS C:\work>