2016-09-12 8 views
2

私はAnsibleモジュールを作成しようとしました。私のモジュールはバグです。私は脚本からそれを実行すると、私は次の読めないの出力を得る:可能なモジュールのデバッグ

$ ansible-playbook lacp.yml 

PLAY [xxxxxxxx] **************************************************************** 

TASK [Test that my module works] *********************************************** 
fatal: [xxxxxxxx]: FAILED! => {"changed": false, "failed": true, "module_stderr": "couldn't set locale correctly\ncouldn't set locale correctly\ncouldn't set locale correctly\nTraceback (most recent call last):\n File \"/tmp/ansible_vHkWq8/ansible_module_lacp.py\", line 27, in <module>\n main()\n File \"/tmp/ansible_vHkWq8/ansible_module_lacp.py\", line 14, in main\n m = re.match('^key: ([0-9]+) ', dladm.readline())\nAttributeError: 'Popen' object has no attribute 'readline'\ndladm: insufficient privileges\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false} 

NO MORE HOSTS LEFT ************************************************************* 
[WARNING]: Could not create retry file 'lacp.retry'.   [Errno 2] No such file or directory: '' 


PLAY RECAP ********************************************************************* 
xxxxxxxx     : ok=0 changed=0 unreachable=0 failed=1 

AnsibleはJSONでエラーメッセージを引用停止する方法は?あるいは、Aniableモジュールをデバッグする別の方法がありますか?

答えて

2

JSONで安全なクォートエラーメッセージを停止する方法はありますか?

human_log.pyプラグインを使用すると、強制的に、出力で改行文字を解釈して印刷することができます。

あなたは/path/to/callback_plugins/ディレクトリにファイルを入れて、ansible.cfgに以下を追加します。

[defaults] 
callback_plugins = /path/to/callback_plugins/ 

詳細な手順は、Human-Readable Ansible Playbook Log Output Using Callback Pluginブログの記事です。

2

あなたはthisthisコールバックプラグイン(Ansible 2.x用)を調べることができます。 module_stderrをそのまま変換しないため、少し修正する必要があります。

また、ANSIBLE_KEEP_REMOTE_FILES=1でプレイブックを実行してから、リモートボックスにsshを実行して、モジュールをその場でデバッグしてから、安全なライブラリに保存してください。

関連する問題