LoginSignup
0
0

More than 5 years have passed since last update.

AWS上のWindowsServerに対して、ローカルmacからansibleを実行 #2 pingテスト実行用のplaybook

Last updated at Posted at 2019-05-27

pingテスト実行用のplaybook。
マニュアルは、https://docs.ansible.com/ansible/latest/modules/win_ping_module.html

pingTest.yml
---
- hosts:
  - windows  # インベントリファイルで指定した名前

  tasks: 
  - name: Test Ping
    win_ping: 
        data: test  # dataを指定しなければpongになる。crashを指定すると、例外が発生する
        # data: crash

以下コマンドで実行。
ansible-playbook -i ./ansible/hosts ./ansible/pingTest.yml

コマンド実行結果

PLAY [windows] ************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************
ok: [ホスト名]

TASK [Test Ping] **********************************************************************************************************************
ok: [ホスト名]

PLAY RECAP ****************************************************************************************************************************
ホスト名 : ok=2    changed=0    unreachable=0    failed=0


なお、data: crashにすると、以下の例外が発生する。

fatal: [ホスト名]: FAILED! => {"changed": false, "module_stderr": "boomAt line:14 char:5+     throw \"boom\"+     ~~~~~~~~~~~~    + CategoryInfo          : OperationStopped: (boom:String) [], RuntimeException    + FullyQualifiedErrorId : boom ", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
    to retry, use: --limit @/Users/kuritayu/git/ansible/pingTest.retry

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