LoginSignup
1
0

More than 5 years have passed since last update.

AWS上のWindowsServerに対して、ローカルmacからansibleを実行 #1

Posted at

AWS上のWindowsServerに対して、ローカルmacからansibleを実行したい、と思った。

環境

  • ローカル(mac)

    • python -> 3.6.4
    • ansible -> 2.7.10
  • リモート(Windows Server 2019)

ローカルの準備

とりあえず、pipでansibleとpywinrmをインストール。

pip install ansible
pip install pywinrm

あと、接続するためのhostsファイルを用意する。私は、ansibleディレクトリを作り、
その下にhostsファイルを作りました。

hosts
[windows]
AWSのパブリックDNS名

[windows:vars]
ansible_user=管理者ユーザ
ansible_password=管理者ユーザのパスワード
ansible_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore

リモートの準備

ansibleで、Windowsの環境を設定するスクリプトが提供されているので、ダウンロード。

Invoke-WebRequest -Uri https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile ConfigureRemotingForAnsible.ps1

で、ダウンロードしたスクリプトを実行する。私のネットワークはパブリックだったので、以下を実行した。

powershell -ExecutionPolicy RemoteSigned .\ConfigureRemotingForAnsible.ps1 -SkipNetworkProfileCheck

AWSの準備

セキュリティグループで、インバウンドルールとして、ポート5986を許可しよう。

動作確認

ansible windows -i ansible/hosts -m win_ping -vvvv

ANSのパブリックDNS名 | SUCCESS => {
"changed": false,
"ping": "pong"
}

的な感じでリターンがあるとOK。

1
0
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
0