
207
10.10 bash でのモジュールの実装
example.com
には、
81
番ポートで待ち受けているサービスがないので、モジュールの実行はわ
かりやすいメッセージを返して失敗するべきです。そしてその通りになります。
* including generated source, if any, saving to:
/Users/lorinhochstein/.ansible_module_generated
* this may offset any line numbers in tracebacks/debuggers!
***********************************
RAW OUTPUT
{"msg": "Could not reach example.com:81", "failed": true}
***********************************
PARSED OUTPUT
{
"failed": true,
"msg": "Could not reach example.com:81"
}
この出力が示唆している通り、
test-module
を実行すると、
Ansible
は
Python
のスクリプトを
生成し、それを
~/.ansible_module_generated
にコピーします。これは、必要なら直接実行する
ことができる、スタンドアローンのスクリプトです。デバッグスクリプトは、以下の行を
Ansible
のリポジトリにあるファイルの
lib/ansible/module_utils/basic.py ...