LoginSignup
4
6

More than 5 years have passed since last update.

Ansible で Windows 7 をターゲットにする準備

Posted at

テストするために、Windows7 をターゲットにしたいときの準備ログ。

自身の環境によるので全ての環境では異なるかもしれない。

PowerShell を上げる

Ansibleでは 3.0 以上が必要なので上げる。

Ansible ホスト pywinrm インストール

# pip install pywinrm

WinRM有効化

コマンドプロンプト管理者権限で実行

> winrm quickconfig

または、PowerShell管理者権限で実行

PS> Enable-PSRemoting

WinRM 有効化コマンド実行時、ファイアウォール機能の例外処理ができない旨のエラーがでた。対処としては、ネットワーク接続の種類を「ホームネットワークへ」(どうも何かの表紙に「パブリックネットワーク」にしてしまっていたから。)

Ansible サイトからアクセスするための準備 ps1 を落とし実行

PS C:\Users\hogek\Desktop> powershell.exe -ExecutionPolicy RemoteSigned .\ConfigureRemotingForAnsible.ps1
(Legacy) Self-signed SSL certificate generated; thumbprint: B9FB031157691488768722BFD6B04C5A9134E332


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                : ja-JP
Address             : http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
ReferenceParameters : ReferenceParameters

OK

参考

Ansible インベントリファイル

hosts
[win]
192.168.0.250
[win:vars]
ansible_user=hogek
ansible_password=password
ansible_ssh_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore # 必要

実行環境

ubuntu@ansible:~/fetch_files$ python --version
Python 2.7.6
ubuntu@ansible:~/fetch_files$ ansible --version
ansible 2.1.2.0
  config file = /home/ubuntu/fetch_files/ansible.cfg
  configured module search path = Default w/o overrides

ubuntu@ansible:~/fetch_files$ ansible -i hosts win -m win_ping
192.168.0.250 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
4
6
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
4
6