1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ansible:Windowsを対象にした際のProxyではまった件について

Last updated at Posted at 2019-07-29

WindowsへのSSH接続がProxyのせいで接続できなかった

Windows側の設定が終わり、Ansibleにて接続確認にてProxyにたどり着かないエラーが出ていた
※社内はProxyサーバーを経由しないと何もできない

# ansible windows -i hosts -m win_ping
XXX.XXX.XXX.XXX | UNREACHABLE! => {
    "changed": false,
    "msg": "ssl: HTTPSConnectionPool(host='XXX.XXX.XXX.XXX', port=5986): Max retries exceeded with url: /wsman (Caused by ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 502 Bad Gateway',)))",
    "unreachable": true
}

原因

  • WindowsへのSSHはHTTPS経由なことと、Ansibleを実行するときはProxyを意識してないからProxy経由にならないこと?

解決策

  • PythonのWinRMのファイルをいじることで解決

これを

/usr/lib/python2.7/site-packages/winrm/transport.py
session.trust_env = True

こう!

/usr/lib/python2.7/site-packages/winrm/transport.py
session.trust_env = False

修正後

# ansible windows -i hosts -m win_ping
XXX.XXX.XXX.XXX | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

とりあえずで書いた記事なので、後日修正予定です

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?